Login
📚 Statistical Inference for Everyone
Chapters ▾

8.5 Computer Examples

from sie import *
data=load_data('data/iris.csv')
x_sertosa=data[data['class']=='Iris-setosa']['petal length [cm]']
x=x_sertosa
mu=sample_mean(x)
N=len(x)
sigma=sample_deviation(x)/sqrt(N)
t_sertosa=tdist(N,mu,sigma)

print "total number of data points:",N
print "best estimate:",mu
print "uncertainty:",sigma
Show expected output
total number of data points: 50
best estimate: 1.464
uncertainty: 0.0245381834898
new_length=1.7
distplot(t_sertosa,label='petal length',xlim=[1.37,1.8],
                 quartiles=[.01,0.05,.5,.95,.99],
)
ax=gca()
ax.axvline(1.7,color='r')
savefig('../../figs/z_test_iris.pdf')
Show expected output
<matplotlib.figure.Figure at 0x10f9d2710>
Posterior distribution for the Setosa iris petal length: a bell curve centered at 1.46 cm with dashed percentile lines at 1.41 (1%), 1.42 (5%), 1.46 (50%), 1.51 (95%) and 1.52 (99%); a red vertical reference line stands far to the right at 1.70 cm, well outside the distribution.

Adapted from Statistical Inference for Everyone, by Brian Blais (Bryant University), licensed under CC BY-SA 4.0 (dual-licensed under the GNU FDL 1.2 or later; this adaptation uses the CC BY-SA grant). Changes were made; this adaptation is distributed under the same license. License: CC-BY-SA-4.0.