[Tutor] confidence interval
afith13 at gmail.com
Thu Jan 14 02:45:40 CET 2010
I have this code for generating a confidence interval from an array of
import numpy as np
import scipy as sp
def mean_confidence_interval(data, confidence=0.95):
a = 1.0*np.array(data)
n = len(a)
m, se = np.mean(a), sp.stats.stderr(a)
h = se * sp.stats.t._ppf((1+confidence)/2., n-1)
return m, m-h, m+h
This works but I feel there's a better and more succinct way to do this.
Does anyone know of an existing python package that can do this for me?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor