Browse Source

Reformatted copernican time

WillKoehrsen 6 years ago
parent
commit
d3b5fee6af
4 changed files with 185 additions and 6385 deletions
  1. 106 52
      copernican/Copernican Principle Time.ipynb
  2. 66 6329
      medium/Stats.ipynb
  3. 9 0
      medium/data/stats-responses.html
  4. 4 4
      medium/data/stats.html

+ 106 - 52
copernican/Copernican Principle Time.ipynb

@@ -46,6 +46,9 @@
    ],
    "source": [
     "# Data science imports\n",
+    "import cufflinks\n",
+    "import plotly.graph_objs as go\n",
+    "import plotly.plotly as py\n",
     "import pandas as pd\n",
     "import numpy as np\n",
     "\n",
@@ -53,9 +56,6 @@
     "from IPython.core.interactiveshell import InteractiveShell\n",
     "InteractiveShell.ast_node_interactivity = 'all'\n",
     "\n",
-    "import plotly.plotly as py\n",
-    "import plotly.graph_objs as go\n",
-    "import cufflinks\n",
     "cufflinks.go_offline()"
    ]
   },
@@ -82,8 +82,8 @@
    "outputs": [],
    "source": [
     "def calculate_multipliers(ci):\n",
-    "    z = (1-ci)/2\n",
-    "    return z/(1-z), (1-z)/z"
+    "    z = (1 - ci) / 2\n",
+    "    return z / (1 - z), (1 - z) / z"
    ]
   },
   {
@@ -146,7 +146,7 @@
    "source": [
     "def calculate_lifetime(t_current, ci):\n",
     "    low, high = calculate_multipliers(ci)\n",
-    "    return t_current*low, t_current*high"
+    "    return t_current * low, t_current * high"
    ]
   },
   {
@@ -226,7 +226,9 @@
     "    low, high = calculate_lifetime(t_current, ci)\n",
     "    now = datetime.now()\n",
     "    try:\n",
-    "        print(f'Estimated lifetime from {(now + timedelta(days=low*365)).date()} ({low:,.2f} years) to {(now + timedelta(days=high*365)).date()} ({high:,.0f} years).')\n",
+    "        print(\n",
+    "            f'Estimated lifetime from {(now + timedelta(days=low*365)).date()} ({low:,.2f} years) to {(now + timedelta(days=high*365)).date()} ({high:,.0f} years).'\n",
+    "        )\n",
     "    except:\n",
     "        print(f'Estimated lifetime in years: {low:,.2f} to {high:,.0f}.')"
    ]
@@ -303,7 +305,7 @@
     }
    ],
    "source": [
-    "print_lifetime(2018-2012, 0.95)"
+    "print_lifetime(2018 - 2012, 0.95)"
    ]
   },
   {
@@ -325,7 +327,7 @@
     }
    ],
    "source": [
-    "print_lifetime(2018-2012, 0.5)"
+    "print_lifetime(2018 - 2012, 0.5)"
    ]
   },
   {
@@ -356,7 +358,7 @@
     }
    ],
    "source": [
-    "print_lifetime(2018-1000, 0.95)"
+    "print_lifetime(2018 - 1000, 0.95)"
    ]
   },
   {
@@ -389,7 +391,7 @@
     }
    ],
    "source": [
-    "print_lifetime(2018-868, 0.95)"
+    "print_lifetime(2018 - 868, 0.95)"
    ]
   },
   {
@@ -420,7 +422,7 @@
     }
    ],
    "source": [
-    "print_lifetime(2018-1220, 0.95)"
+    "print_lifetime(2018 - 1220, 0.95)"
    ]
   },
   {
@@ -2538,18 +2540,34 @@
    ],
    "source": [
     "df = pd.DataFrame({'x': x, 'y': y})\n",
-    "df.iplot(x='x', y='y', layout=dict(xaxis=dict(type='log', tickfont=dict(size=16),\n",
-    "                                              titlefont=dict(size=18),\n",
-    "                                              title=r'$\\frac{t_{future}}{t_{currrent}}$'),\n",
-    "                                  yaxis=dict(title='probability'), title = 'PDF',\n",
-    "                                   shapes=[dict(type='line',\n",
-    "                                               x0 = 39, x1= 39, \n",
-    "                                               y0 = 0, y1=1,\n",
-    "                                               line=dict(color='black', dash='dash')),\n",
-    "                                          dict(type='line',\n",
-    "                                               x0 = 1/39, x1= 1/39, \n",
-    "                                               y0 = 0, y1=1, name='39',\n",
-    "                                               line=dict(color='black', dash='dash'))]))"
+    "df.iplot(\n",
+    "    x='x',\n",
+    "    y='y',\n",
+    "    layout=dict(\n",
+    "        xaxis=dict(\n",
+    "            type='log',\n",
+    "            tickfont=dict(size=16),\n",
+    "            titlefont=dict(size=18),\n",
+    "            title=r'$\\frac{t_{future}}{t_{currrent}}$'),\n",
+    "        yaxis=dict(title='probability'),\n",
+    "        title='PDF',\n",
+    "        shapes=[\n",
+    "            dict(\n",
+    "                type='line',\n",
+    "                x0=39,\n",
+    "                x1=39,\n",
+    "                y0=0,\n",
+    "                y1=1,\n",
+    "                line=dict(color='black', dash='dash')),\n",
+    "            dict(\n",
+    "                type='line',\n",
+    "                x0=1 / 39,\n",
+    "                x1=1 / 39,\n",
+    "                y0=0,\n",
+    "                y1=1,\n",
+    "                name='39',\n",
+    "                line=dict(color='black', dash='dash'))\n",
+    "        ]))"
    ]
   },
   {
@@ -4653,20 +4671,38 @@
    "source": [
     "t_c = 6\n",
     "df = pd.DataFrame({'x': x * t_c, 'y': y})\n",
-    "annotations = [dict(x=np.log10(39*t_c), y = 0.5, text = '95% upper limit'),\n",
-    "               dict(x=np.log10(1/39*t_c), y = 0.5, text = '95% lower limit')]\n",
-    "df.iplot(x='x', y='y', layout=dict(annotations=annotations,\n",
-    "    xaxis=dict(type='log', tickfont=dict(size=16),\n",
-    "                                              title=r'$t_{future} \\text{ (years)}$'),\n",
-    "                                  yaxis=dict(title='probability'), title = 'PDF for Lifetime of Data Science',\n",
-    "                                   shapes=[dict(type='line',\n",
-    "                                               x0 = 39 * t_c, x1= 39*t_c, \n",
-    "                                               y0 = 0, y1=1,\n",
-    "                                               line=dict(color='black', dash='dash')),\n",
-    "                                          dict(type='line',\n",
-    "                                               x0 = (1/39)*t_c, x1= (1/39)*t_c, \n",
-    "                                               y0 = 0, y1=1, name='39',\n",
-    "                                               line=dict(color='black', dash='dash'))]))"
+    "annotations = [\n",
+    "    dict(x=np.log10(39 * t_c), y=0.5, text='95% upper limit'),\n",
+    "    dict(x=np.log10(1 / 39 * t_c), y=0.5, text='95% lower limit')\n",
+    "]\n",
+    "df.iplot(\n",
+    "    x='x',\n",
+    "    y='y',\n",
+    "    layout=dict(\n",
+    "        annotations=annotations,\n",
+    "        xaxis=dict(\n",
+    "            type='log',\n",
+    "            tickfont=dict(size=16),\n",
+    "            title=r'$t_{future} \\text{ (years)}$'),\n",
+    "        yaxis=dict(title='probability'),\n",
+    "        title='PDF for Lifetime of Data Science',\n",
+    "        shapes=[\n",
+    "            dict(\n",
+    "                type='line',\n",
+    "                x0=39 * t_c,\n",
+    "                x1=39 * t_c,\n",
+    "                y0=0,\n",
+    "                y1=1,\n",
+    "                line=dict(color='black', dash='dash')),\n",
+    "            dict(\n",
+    "                type='line',\n",
+    "                x0=(1 / 39) * t_c,\n",
+    "                x1=(1 / 39) * t_c,\n",
+    "                y0=0,\n",
+    "                y1=1,\n",
+    "                name='39',\n",
+    "                line=dict(color='black', dash='dash'))\n",
+    "        ]))"
    ]
   },
   {
@@ -6770,20 +6806,38 @@
    "source": [
     "t_c = 200000\n",
     "df = pd.DataFrame({'x': x * t_c, 'y': y})\n",
-    "annotations = [dict(x=np.log10(39*t_c), y = 0.5, text = '95% upper limit'),\n",
-    "               dict(x=np.log10(1/39*t_c), y = 0.5, text = '95% lower limit')]\n",
-    "df.iplot(x='x', y='y', layout=dict(annotations=annotations,\n",
-    "    xaxis=dict(type='log', tickfont=dict(size=16),\n",
-    "                                              title=r'$t_{future} \\text{ (years)}$'),\n",
-    "                                  yaxis=dict(title='probability'), title = 'PDF for Lifetime of Human Species',\n",
-    "                                   shapes=[dict(type='line',\n",
-    "                                               x0 = 39 * t_c, x1= 39*t_c, \n",
-    "                                               y0 = 0, y1=1,\n",
-    "                                               line=dict(color='black', dash='dash')),\n",
-    "                                          dict(type='line',\n",
-    "                                               x0 = (1/39)*t_c, x1= (1/39)*t_c, \n",
-    "                                               y0 = 0, y1=1, name='39',\n",
-    "                                               line=dict(color='black', dash='dash'))]))"
+    "annotations = [\n",
+    "    dict(x=np.log10(39 * t_c), y=0.5, text='95% upper limit'),\n",
+    "    dict(x=np.log10(1 / 39 * t_c), y=0.5, text='95% lower limit')\n",
+    "]\n",
+    "df.iplot(\n",
+    "    x='x',\n",
+    "    y='y',\n",
+    "    layout=dict(\n",
+    "        annotations=annotations,\n",
+    "        xaxis=dict(\n",
+    "            type='log',\n",
+    "            tickfont=dict(size=16),\n",
+    "            title=r'$t_{future} \\text{ (years)}$'),\n",
+    "        yaxis=dict(title='probability'),\n",
+    "        title='PDF for Lifetime of Human Species',\n",
+    "        shapes=[\n",
+    "            dict(\n",
+    "                type='line',\n",
+    "                x0=39 * t_c,\n",
+    "                x1=39 * t_c,\n",
+    "                y0=0,\n",
+    "                y1=1,\n",
+    "                line=dict(color='black', dash='dash')),\n",
+    "            dict(\n",
+    "                type='line',\n",
+    "                x0=(1 / 39) * t_c,\n",
+    "                x1=(1 / 39) * t_c,\n",
+    "                y0=0,\n",
+    "                y1=1,\n",
+    "                name='39',\n",
+    "                line=dict(color='black', dash='dash'))\n",
+    "        ]))"
    ]
   },
   {

File diff suppressed because it is too large
+ 66 - 6329
medium/Stats.ipynb


File diff suppressed because it is too large
+ 9 - 0
medium/data/stats-responses.html


File diff suppressed because it is too large
+ 4 - 4
medium/data/stats.html