Przeglądaj źródła

Add files via upload

Michael Pyrcz 1 tydzień temu
rodzic
commit
7c059d7296
1 zmienionych plików z 25 dodań i 19 usunięć
  1. 25 19
      Interactive_Bayesian_Updating.ipynb

+ 25 - 19
Interactive_Bayesian_Updating.ipynb

@@ -102,7 +102,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 1,
+   "execution_count": 10,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -140,7 +140,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
+   "execution_count": 11,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -177,7 +177,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": 12,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -283,13 +283,13 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 13,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "497996fed9b54cf7ad359e5ecab0098b",
+       "model_id": "f9678e0cf8d0408fb52571c37a04b9cd",
        "version_major": 2,
        "version_minor": 0
       },
@@ -303,12 +303,12 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "0c3b483a31a7405ca003da355c8d1cf7",
+       "model_id": "832c543dac4c4eb18369c20d18cff658",
        "version_major": 2,
        "version_minor": 0
       },
       "text/plain": [
-       "Output()"
+       "Output(outputs=({'output_type': 'display_data', 'data': {'text/plain': '<Figure size 640x480 with 1 Axes>', 'i…"
       ]
      },
      "metadata": {},
@@ -343,7 +343,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 14,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -531,13 +531,13 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 15,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "e83a5df3674e4e4b863b66f0ce6ad940",
+       "model_id": "21d4686df24f466aa17cc2e6692df35e",
        "version_major": 2,
        "version_minor": 0
       },
@@ -551,7 +551,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "a9ccd02bb35b4b5cb97e43d9408c85fa",
+       "model_id": "5c8e204f500f4d86beb1463c7beb3d8a",
        "version_major": 2,
        "version_minor": 0
       },
@@ -604,7 +604,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 16,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -699,11 +699,11 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 41,
    "metadata": {},
    "outputs": [],
    "source": [
-    "l = widgets.Text(value='                                 Gold Resources Bayesian Updating Demo, Michael Pyrcz, Professor, The University of Texas at Austin',\n",
+    "l = widgets.Text(value='                                 Gold Reserves Bayesian Updating Demo, Michael Pyrcz, Professor, The University of Texas at Austin',\n",
     "        layout=Layout(width='900px', height='30px'))\n",
     "# P_happening_label = widgets.Text(value='Probability of Happening',layout=Layout(width='50px',height='30px',line-size='0 px'))\n",
     "mu_prior = widgets.FloatSlider(min=0.0, max = 2.0, value=0.5, step = 0.1, description = r'$\\mu_{Au,prior}$',orientation='horizontal', \n",
@@ -741,6 +741,12 @@
     "    plt.plot(values,PDF_prior,c='green',label='Prior, Exploration',zorder=10); plt.fill_between(values,PDF_prior,color='green',alpha=0.05,zorder=1)\n",
     "    plt.plot(values,PDF_like,c='red',label='Likelihood, New Appraisal Data',zorder=10); plt.fill_between(values,PDF_like,color='red',alpha=0.05,zorder=1) \n",
     "    plt.plot(values,PDF_post,c='black',label='Posterior, Exploration + New Appraisal Data',zorder=10); plt.fill_between(values,PDF_post,color='black',alpha=0.05,zorder=1)\n",
+    "\n",
+    "    P10 = st.norm.ppf(0.1, loc = mu_post,scale = math.sqrt(sigma2_post))\n",
+    "    P90 = st.norm.ppf(0.9, loc = mu_post,scale = math.sqrt(sigma2_post))\n",
+    "    plt.annotate('Posterior, P10 =    ' + str(np.round(P10,2)) + ' million ounces', [1.0,8.0])\n",
+    "    plt.annotate('Posterior, mean = ' + str(np.round(mu_post,2)) + ' million ounces', [1.0,7.6])\n",
+    "    plt.annotate('Posterior, P90 =    ' + str(np.round(P90,2)) + ' million ounces', [1.0,7.2])\n",
     "    \n",
     "    plt.xlabel('Gold Reserves (million ounces)'); plt.ylabel('Density'); plt.title('Gold Mine Reserves, Bayesian Updating Gaussian, PDFs')\n",
     "    plt.xlim([0.0,2.0]); plt.ylim(0,10); add_grid(); plt.legend(loc = 'upper left')\n",
@@ -749,7 +755,7 @@
     "    plt.plot(Perc_prior,pvalues,c='green',label='Prior, Exploration')\n",
     "    plt.plot(Perc_like,pvalues,c='red',label='Likelihood, New Appraisal Data')\n",
     "    plt.plot(Perc_post,pvalues,c='black',label='Posterior, Exploration + New Appraisal Data')\n",
-    "    \n",
+    "   \n",
     "    plt.xlabel('Gold Reserves (million ounces)'); plt.ylabel('Cumulative Probability'); plt.title('Gold Mine Reserves, Bayesian Updating Gaussian, CDFs')\n",
     "    plt.xlim([0.,2.0]); plt.ylim([0,1]); add_grid(); plt.legend(loc = 'lower right')\n",
     "    \n",
@@ -762,18 +768,18 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 42,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "81b6b594d997431ead0cbbb11e09ccc4",
+       "model_id": "6b239de7e7ca449b9498559d2222dcb0",
        "version_major": 2,
        "version_minor": 0
       },
       "text/plain": [
-       "VBox(children=(Text(value='                                 Gold Resources Bayesian Updating Demo, Michael Pyr…"
+       "VBox(children=(Text(value='                                 Gold Reserves Bayesian Updating Demo, Michael Pyrc…"
       ]
      },
      "metadata": {},
@@ -782,7 +788,7 @@
     {
      "data": {
       "application/vnd.jupyter.widget-view+json": {
-       "model_id": "cc553ae2726f4a9e930f9da3f026a380",
+       "model_id": "afa53fb521d54839a32059b3bc8f5281",
        "version_major": 2,
        "version_minor": 0
       },