105 lines
7.9 KiB
Plaintext
105 lines
7.9 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:
|
|
------------------
|
|
%matplotlib inline
|
|
|
|
from numpy import *
|
|
from numpy.random import randint, randn
|
|
from time import time
|
|
import matplotlib.mlab as mlab
|
|
import matplotlib.pyplot as plt
|
|
|
|
# Returns mean of bootstrap samples
|
|
def stat(data):
|
|
return mean(data)
|
|
|
|
# Bootstrap algorithm
|
|
def bootstrap(data, statistic, R):
|
|
t = zeros(R); n = len(data); inds = arange(n); t0 = time()
|
|
# non-parametric bootstrap
|
|
for i in range(R):
|
|
t[i] = statistic(data[randint(0,n,n)])
|
|
|
|
# analysis
|
|
print("Runtime: %g sec" % (time()-t0)); print("Bootstrap Statistics :")
|
|
print("original bias std. error")
|
|
print("%8g %8g %14g %15g" % (statistic(data), std(data),mean(t),std(t)))
|
|
return t
|
|
|
|
|
|
mu, sigma = 100, 15
|
|
datapoints = 10000
|
|
x = mu + sigma*random.randn(datapoints)
|
|
# bootstrap returns the data sample
|
|
t = bootstrap(x, stat, datapoints)
|
|
# the histogram of the bootstrapped data
|
|
n, binsboot, patches = plt.hist(t, 50, normed=1, facecolor='red', alpha=0.75)
|
|
|
|
# add a 'best fit' line
|
|
y = mlab.normpdf( binsboot, mean(t), std(t))
|
|
lt = plt.plot(binsboot, y, 'r--', linewidth=1)
|
|
plt.xlabel('Smarts')
|
|
plt.ylabel('Probability')
|
|
plt.axis([99.5, 100.6, 0, 3.0])
|
|
plt.grid(True)
|
|
|
|
plt.show()
|
|
------------------
|
|
|
|
[0;31m---------------------------------------------------------------------------[0m
|
|
[0;31mAttributeError[0m Traceback (most recent call last)
|
|
[0;32m<ipython-input-2-772b904ae9cb>[0m in [0;36m<module>[0;34m[0m
|
|
[1;32m 31[0m [0mt[0m [0;34m=[0m [0mbootstrap[0m[0;34m([0m[0mx[0m[0;34m,[0m [0mstat[0m[0;34m,[0m [0mdatapoints[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
[1;32m 32[0m [0;31m# the histogram of the bootstrapped data[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m
|
|
[0;32m---> 33[0;31m [0mn[0m[0;34m,[0m [0mbinsboot[0m[0;34m,[0m [0mpatches[0m [0;34m=[0m [0mplt[0m[0;34m.[0m[0mhist[0m[0;34m([0m[0mt[0m[0;34m,[0m [0;36m50[0m[0;34m,[0m [0mnormed[0m[0;34m=[0m[0;36m1[0m[0;34m,[0m [0mfacecolor[0m[0;34m=[0m[0;34m'red'[0m[0;34m,[0m [0malpha[0m[0;34m=[0m[0;36m0.75[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
[0m[1;32m 34[0m [0;34m[0m[0m
|
|
[1;32m 35[0m [0;31m# add a 'best fit' line[0m[0;34m[0m[0;34m[0m[0;34m[0m[0m
|
|
|
|
[0;32m~/opt/anaconda3/lib/python3.8/site-packages/matplotlib/pyplot.py[0m in [0;36mhist[0;34m(x, bins, range, density, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, data, **kwargs)[0m
|
|
[1;32m 2683[0m [0morientation[0m[0;34m=[0m[0;34m'vertical'[0m[0;34m,[0m [0mrwidth[0m[0;34m=[0m[0;32mNone[0m[0;34m,[0m [0mlog[0m[0;34m=[0m[0;32mFalse[0m[0;34m,[0m [0mcolor[0m[0;34m=[0m[0;32mNone[0m[0;34m,[0m[0;34m[0m[0;34m[0m[0m
|
|
[1;32m 2684[0m label=None, stacked=False, *, data=None, **kwargs):
|
|
[0;32m-> 2685[0;31m return gca().hist(
|
|
[0m[1;32m 2686[0m [0mx[0m[0;34m,[0m [0mbins[0m[0;34m=[0m[0mbins[0m[0;34m,[0m [0mrange[0m[0;34m=[0m[0mrange[0m[0;34m,[0m [0mdensity[0m[0;34m=[0m[0mdensity[0m[0;34m,[0m [0mweights[0m[0;34m=[0m[0mweights[0m[0;34m,[0m[0;34m[0m[0;34m[0m[0m
|
|
[1;32m 2687[0m [0mcumulative[0m[0;34m=[0m[0mcumulative[0m[0;34m,[0m [0mbottom[0m[0;34m=[0m[0mbottom[0m[0;34m,[0m [0mhisttype[0m[0;34m=[0m[0mhisttype[0m[0;34m,[0m[0;34m[0m[0;34m[0m[0m
|
|
|
|
[0;32m~/opt/anaconda3/lib/python3.8/site-packages/matplotlib/__init__.py[0m in [0;36minner[0;34m(ax, data, *args, **kwargs)[0m
|
|
[1;32m 1445[0m [0;32mdef[0m [0minner[0m[0;34m([0m[0max[0m[0;34m,[0m [0;34m*[0m[0margs[0m[0;34m,[0m [0mdata[0m[0;34m=[0m[0;32mNone[0m[0;34m,[0m [0;34m**[0m[0mkwargs[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
|
|
[1;32m 1446[0m [0;32mif[0m [0mdata[0m [0;32mis[0m [0;32mNone[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
|
|
[0;32m-> 1447[0;31m [0;32mreturn[0m [0mfunc[0m[0;34m([0m[0max[0m[0;34m,[0m [0;34m*[0m[0mmap[0m[0;34m([0m[0msanitize_sequence[0m[0;34m,[0m [0margs[0m[0;34m)[0m[0;34m,[0m [0;34m**[0m[0mkwargs[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
[0m[1;32m 1448[0m [0;34m[0m[0m
|
|
[1;32m 1449[0m [0mbound[0m [0;34m=[0m [0mnew_sig[0m[0;34m.[0m[0mbind[0m[0;34m([0m[0max[0m[0;34m,[0m [0;34m*[0m[0margs[0m[0;34m,[0m [0;34m**[0m[0mkwargs[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
|
|
[0;32m~/opt/anaconda3/lib/python3.8/site-packages/matplotlib/axes/_axes.py[0m in [0;36mhist[0;34m(self, x, bins, range, density, weights, cumulative, bottom, histtype, align, orientation, rwidth, log, color, label, stacked, **kwargs)[0m
|
|
[1;32m 6813[0m [0;32mif[0m [0mpatch[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
|
|
[1;32m 6814[0m [0mp[0m [0;34m=[0m [0mpatch[0m[0;34m[[0m[0;36m0[0m[0;34m][0m[0;34m[0m[0;34m[0m[0m
|
|
[0;32m-> 6815[0;31m [0mp[0m[0;34m.[0m[0mupdate[0m[0;34m([0m[0mkwargs[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
[0m[1;32m 6816[0m [0;32mif[0m [0mlbl[0m [0;32mis[0m [0;32mnot[0m [0;32mNone[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
|
|
[1;32m 6817[0m [0mp[0m[0;34m.[0m[0mset_label[0m[0;34m([0m[0mlbl[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
|
|
[0;32m~/opt/anaconda3/lib/python3.8/site-packages/matplotlib/artist.py[0m in [0;36mupdate[0;34m(self, props)[0m
|
|
[1;32m 994[0m [0mfunc[0m [0;34m=[0m [0mgetattr[0m[0;34m([0m[0mself[0m[0;34m,[0m [0;34mf"set_{k}"[0m[0;34m,[0m [0;32mNone[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
[1;32m 995[0m [0;32mif[0m [0;32mnot[0m [0mcallable[0m[0;34m([0m[0mfunc[0m[0;34m)[0m[0;34m:[0m[0;34m[0m[0;34m[0m[0m
|
|
[0;32m--> 996[0;31m raise AttributeError(f"{type(self).__name__!r} object "
|
|
[0m[1;32m 997[0m f"has no property {k!r}")
|
|
[1;32m 998[0m [0mret[0m[0;34m.[0m[0mappend[0m[0;34m([0m[0mfunc[0m[0;34m([0m[0mv[0m[0;34m)[0m[0;34m)[0m[0;34m[0m[0;34m[0m[0m
|
|
|
|
[0;31mAttributeError[0m: 'Rectangle' object has no property 'normed'
|
|
AttributeError: 'Rectangle' object has no property 'normed'
|
|
|