47 lines
3.4 KiB
Plaintext
47 lines
3.4 KiB
Plaintext
Traceback (most recent call last):
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/jupyter_cache/executors/utils.py", line 51, in single_nb_execution
|
|
executenb(
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 1087, in execute
|
|
return NotebookClient(nb=nb, resources=resources, km=km, **kwargs).execute()
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/util.py", line 74, in wrapped
|
|
return just_run(coro(*args, **kwargs))
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/util.py", line 53, in just_run
|
|
return loop.run_until_complete(coro)
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
|
|
return future.result()
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 540, in async_execute
|
|
await self.async_execute_cell(
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 832, in async_execute_cell
|
|
self._check_raise_for_error(cell, exec_reply)
|
|
File "/Users/mhjensen/opt/anaconda3/lib/python3.8/site-packages/nbclient/client.py", line 740, in _check_raise_for_error
|
|
raise CellExecutionError.from_cell_and_msg(cell, exec_reply['content'])
|
|
nbclient.exceptions.CellExecutionError: An error occurred while executing the following cell:
|
|
------------------
|
|
heads_proba = 0.51
|
|
coin_tosses = (np.random.rand(10000, 10) < heads_proba).astype(np.int32)
|
|
cumulative_heads_ratio = np.cumsum(coin_tosses, axis=0) / np.arange(1, 10001).reshape(-1, 1)
|
|
plt.figure(figsize=(8,3.5))
|
|
plt.plot(cumulative_heads_ratio)
|
|
plt.plot([0, 10000], [0.51, 0.51], "k--", linewidth=2, label="51%")
|
|
plt.plot([0, 10000], [0.5, 0.5], "k-", label="50%")
|
|
plt.xlabel("Number of coin tosses")
|
|
plt.ylabel("Heads ratio")
|
|
plt.legend(loc="lower right")
|
|
plt.axis([0, 10000, 0.42, 0.58])
|
|
save_fig("votingsimple")
|
|
plt.show()
|
|
------------------
|
|
|
|
[0;31m---------------------------------------------------------------------------[0m
|
|
[0;31mNameError[0m Traceback (most recent call last)
|
|
[0;32m<ipython-input-1-eface79dac2c>[0m in [0;36m<module>[0;34m[0m
|
|
[1;32m 1[0m [0mheads_proba[0m [0;34m=[0m [0;36m0.51[0m[0;34m[0m[0;34m[0m[0m
|
|
[0;32m----> 2[0;31m [0mcoin_tosses[0m [0;34m=[0m [0;34m([0m[0mnp[0m[0;34m.[0m[0mrandom[0m[0;34m.[0m[0mrand[0m[0;34m([0m[0;36m10000[0m[0;34m,[0m [0;36m10[0m[0;34m)[0m [0;34m<[0m [0mheads_proba[0m[0;34m)[0m[0;34m.[0m[0mastype[0m[0;34m([0m[0mnp[0m[0;34m.[0m[0mint32[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
[0m[1;32m 3[0m [0mcumulative_heads_ratio[0m [0;34m=[0m [0mnp[0m[0;34m.[0m[0mcumsum[0m[0;34m([0m[0mcoin_tosses[0m[0;34m,[0m [0maxis[0m[0;34m=[0m[0;36m0[0m[0;34m)[0m [0;34m/[0m [0mnp[0m[0;34m.[0m[0marange[0m[0;34m([0m[0;36m1[0m[0;34m,[0m [0;36m10001[0m[0;34m)[0m[0;34m.[0m[0mreshape[0m[0;34m([0m[0;34m-[0m[0;36m1[0m[0;34m,[0m [0;36m1[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
[1;32m 4[0m [0mplt[0m[0;34m.[0m[0mfigure[0m[0;34m([0m[0mfigsize[0m[0;34m=[0m[0;34m([0m[0;36m8[0m[0;34m,[0m[0;36m3.5[0m[0;34m)[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
[1;32m 5[0m [0mplt[0m[0;34m.[0m[0mplot[0m[0;34m([0m[0mcumulative_heads_ratio[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
|
|
[0;31mNameError[0m: name 'np' is not defined
|
|
NameError: name 'np' is not defined
|
|
|