Am I using z-score or t-score for my confidence interval?
I would like to estimate the average of the dataset that I have.
I have 1000 data points and I read somewhere that if your sample size is less than 30 you should use t-count, otherwise use z estimate.
Here is the code I am using
def mean_confidence_interval(data,confidence = 0.95):
from numpy import mean,array
import scipy as sp
import scipy.stats
a = array(data)
n = len(a)
m, se = mean(a), scipy.stats.sem(a)
h = se*sp.stats.t._ppf( (1+confidence)/2., n-1)
return m, h, (m-h,m+h)
I am wondering what function can I use insteaf sp.stats.t._ppf
to calculate the correct z value.
+3
user3600497
source
to share
1 answer
You use the z-score / test when the population standard deviation is known and the t-score / test when it is estimated from the data. For large samples (~ 30) they become the same. So in your case, I would just use your t-score confidence intervals for everything.
+1
Sealander
source
to share