Created using Colaboratory
This commit is contained in:
@@ -4,7 +4,6 @@
|
|||||||
"metadata": {
|
"metadata": {
|
||||||
"colab": {
|
"colab": {
|
||||||
"provenance": [],
|
"provenance": [],
|
||||||
"authorship_tag": "ABX9TyOJeBMhN9fXO8UepZ4+Pbg6",
|
|
||||||
"include_colab_link": true
|
"include_colab_link": true
|
||||||
},
|
},
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
@@ -433,12 +432,25 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"source": [
|
"source": [
|
||||||
"# Now let's plot the likelihood, negative log likelihood, and least squares as a function the value of the offset beta1\n",
|
"# Now let's plot the likelihood, negative log likelihood, and least squares as a function the value of the offset beta1\n",
|
||||||
"fig, ax = plt.subplots(1,3)\n",
|
"fig, ax = plt.subplots(1,2)\n",
|
||||||
"fig.set_size_inches(10.5, 3.5)\n",
|
"fig.set_size_inches(10.5, 5.5)\n",
|
||||||
"fig.tight_layout(pad=3.0)\n",
|
"fig.tight_layout(pad=10.0)\n",
|
||||||
"ax[0].plot(beta_1_vals, likelihoods); ax[0].set_xlabel('beta_1[0]$'); ax[0].set_ylabel('likelihood')\n",
|
"likelihood_color = 'tab:red'\n",
|
||||||
"ax[1].plot(beta_1_vals, nlls); ax[1].set_xlabel('beta_1[0]'); ax[1].set_ylabel('negative log likelihood')\n",
|
"nll_color = 'tab:blue'\n",
|
||||||
"ax[2].plot(beta_1_vals, sum_squares); ax[2].set_xlabel('beta_1[0]'); ax[2].set_ylabel('sum of squares')\n",
|
"\n",
|
||||||
|
"ax[0].set_xlabel('beta_1[0, 0]')\n",
|
||||||
|
"ax[0].set_ylabel('likelihood', color = likelihood_color)\n",
|
||||||
|
"ax[0].plot(beta_1_vals, likelihoods, color = likelihood_color)\n",
|
||||||
|
"ax[0].tick_params(axis='y', labelcolor=likelihood_color)\n",
|
||||||
|
"\n",
|
||||||
|
"ax00 = ax[0].twinx()\n",
|
||||||
|
"ax00.plot(beta_1_vals, nlls, color = nll_color)\n",
|
||||||
|
"ax00.set_ylabel('negative log likelihood', color = nll_color)\n",
|
||||||
|
"ax00.tick_params(axis='y', labelcolor = nll_color)\n",
|
||||||
|
"\n",
|
||||||
|
"plt.axvline(x = beta_1_vals[np.argmax(likelihoods)], linestyle='dotted')\n",
|
||||||
|
"\n",
|
||||||
|
"ax[1].plot(beta_1_vals, sum_squares); ax[1].set_xlabel('beta_1[0]'); ax[1].set_ylabel('sum of squares')\n",
|
||||||
"plt.show()"
|
"plt.show()"
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -519,12 +531,26 @@
|
|||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"source": [
|
"source": [
|
||||||
"# Now let's plot the likelihood, negative log likelihood, and least squares as a function the value of the standard divation sigma\n",
|
"# Now let's plot the likelihood, negative log likelihood, and least squares as a function the value of the standard divation sigma\n",
|
||||||
"fig, ax = plt.subplots(1,3)\n",
|
"fig, ax = plt.subplots(1,2)\n",
|
||||||
"fig.set_size_inches(10.5, 3.5)\n",
|
"fig.set_size_inches(10.5, 5.5)\n",
|
||||||
"fig.tight_layout(pad=3.0)\n",
|
"fig.tight_layout(pad=10.0)\n",
|
||||||
"ax[0].plot(sigma_vals, likelihoods); ax[0].set_xlabel('$\\sigma$'); ax[0].set_ylabel('likelihood')\n",
|
"likelihood_color = 'tab:red'\n",
|
||||||
"ax[1].plot(sigma_vals, nlls); ax[1].set_xlabel('$\\sigma$'); ax[1].set_ylabel('negative log likelihood')\n",
|
"nll_color = 'tab:blue'\n",
|
||||||
"ax[2].plot(sigma_vals, sum_squares); ax[2].set_xlabel('$\\sigma$'); ax[2].set_ylabel('sum of squares')\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"ax[0].set_xlabel('sigma')\n",
|
||||||
|
"ax[0].set_ylabel('likelihood', color = likelihood_color)\n",
|
||||||
|
"ax[0].plot(sigma_vals, likelihoods, color = likelihood_color)\n",
|
||||||
|
"ax[0].tick_params(axis='y', labelcolor=likelihood_color)\n",
|
||||||
|
"\n",
|
||||||
|
"ax00 = ax[0].twinx()\n",
|
||||||
|
"ax00.plot(sigma_vals, nlls, color = nll_color)\n",
|
||||||
|
"ax00.set_ylabel('negative log likelihood', color = nll_color)\n",
|
||||||
|
"ax00.tick_params(axis='y', labelcolor = nll_color)\n",
|
||||||
|
"\n",
|
||||||
|
"plt.axvline(x = sigma_vals[np.argmax(likelihoods)], linestyle='dotted')\n",
|
||||||
|
"\n",
|
||||||
|
"ax[1].plot(sigma_vals, sum_squares); ax[1].set_xlabel('sigma'); ax[1].set_ylabel('sum of squares')\n",
|
||||||
"plt.show()"
|
"plt.show()"
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
@@ -564,4 +590,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user