Blog Archive

Showing posts with label Statistics. Show all posts
Showing posts with label Statistics. Show all posts

Monday, December 3, 2012

Confidence Intervals in Python



from scipy import stats
import scipy as sp
import numpy as np

s = np.array([1,2,3,4,4,4,5,5,5,5,4,4,4,6,7,8])
n, min_max, mean, var, skew, kurt = stats.describe(s)
std=math.sqrt(var)

#note these are sample standard deviations 
#and sample variance values
#to get population values s.std() and s.var() will work


#The location (loc) keyword specifies the mean.
#The scale (scale) keyword specifies the standard deviation.

# We will assume a normal distribution
R = stats.norm.interval(0.05,loc=mean,scale=std)


>>> R
(4.33017855099411, 4.54482144900589)