Hi tutor,

I have this code for generating a confidence interval from an array of
values:
  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?

Thanks,

-Drew
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to