03: Add TODO note, falsely solve 2a
This commit is contained in:
@ -272,7 +272,8 @@
|
|||||||
"plt.ylabel(\"$p_X(k)$\")\n",
|
"plt.ylabel(\"$p_X(k)$\")\n",
|
||||||
"plt.xlabel(\"$k$\")\n",
|
"plt.xlabel(\"$k$\")\n",
|
||||||
"plt.legend()\n",
|
"plt.legend()\n",
|
||||||
"plt.show()"
|
"plt.show()\n",
|
||||||
|
"# TODO: The histogram overshoots the theoretical value every time."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -337,7 +338,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": 7,
|
||||||
"id": "bbf5c843",
|
"id": "bbf5c843",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"deletable": false,
|
"deletable": false,
|
||||||
@ -353,10 +354,32 @@
|
|||||||
"task": false
|
"task": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"\n",
|
||||||
|
"After trial and error, I found that 43402 trials were sufficient to arrive at an 1-sigma error of around 0.001,\n",
|
||||||
|
"with mean 0.486440 and standard deviation sigma 0.000998. Wolfram Alpha tells me it should be approximately I =\n",
|
||||||
|
"0.487595, so I am happy.\n",
|
||||||
|
" \n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"# YOUR CODE HERE\n",
|
"def sample_X():\n",
|
||||||
"raise NotImplementedError()"
|
" x = rng.random()\n",
|
||||||
|
" return np.sin(np.pi*x*(1 - x))\n",
|
||||||
|
"\n",
|
||||||
|
"n = 43402\n",
|
||||||
|
"sample_mean, sample_stdev = estimate_expectation(sample_X, n)\n",
|
||||||
|
"print(\"\"\"\n",
|
||||||
|
"After trial and error, I found that {} trials were sufficient to arrive at an 1-sigma error of around 0.001,\n",
|
||||||
|
"with mean {:.6f} and standard deviation sigma {:.6f}. Wolfram Alpha tells me it should be approximately I =\n",
|
||||||
|
"{}, so I am happy.\n",
|
||||||
|
" \"\"\".format(n, sample_mean, sample_stdev, 0.487595))\n",
|
||||||
|
"# TODO: Maybe I did not answer the question. Reading is difficult."
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user