[Scipy-tickets] [SciPy] #1492: stats.normaltest raises ValueError when the sample size is too small (but not in a nice way)

SciPy Trac scipy-tickets@scipy....
Sun Aug 7 21:39:23 CDT 2011


#1492: stats.normaltest raises ValueError when the sample size is too small (but
not in a nice way)
------------------------------+---------------------------------------------
 Reporter:  warren.weckesser  |       Owner:  somebody
     Type:  defect            |      Status:  new     
 Priority:  normal            |   Milestone:  0.10.0  
Component:  scipy.stats       |     Version:  0.9.0   
 Keywords:                    |  
------------------------------+---------------------------------------------
 When the sample size passed to stats.normaltest is less than 8, we get,
 for example,
 {{{
 In [1]: from scipy.stats import normaltest

 In [2]: normaltest(arange(5))
 /Users/warren/local_scipy/lib/python2.7/site-
 packages/scipy/stats/stats.py:1155: UserWarning: skewtest only valid for
 n>=8 ... continuing anyway, n=5
   int(n))
 ---------------------------------------------------------------------------
 ValueError                                Traceback (most recent call
 last)
 /Users/warren/<ipython-input-2-a4c290b2d4a5> in <module>()
 ----> 1 normaltest(arange(5))

 /Users/warren/local_scipy/lib/python2.7/site-
 packages/scipy/stats/stats.pyc in normaltest(a, axis)
    1253     """
    1254     a, axis = _chk_asarray(a, axis)
 -> 1255     s,p = skewtest(a,axis)
    1256     k,p = kurtosistest(a,axis)
    1257     k2 = s*s + k*k

 /Users/warren/local_scipy/lib/python2.7/site-
 packages/scipy/stats/stats.pyc in skewtest(a, axis)
    1157     beta2 = ( 3.0*(n*n+27*n-70)*(n+1)*(n+3) ) / (
 (n-2.0)*(n+5)*(n+7)*(n+9) )
    1158     W2 = -1 + math.sqrt(2*(beta2-1))
 -> 1159     delta = 1/math.sqrt(0.5*math.log(W2))
    1160     alpha = math.sqrt(2.0/(W2-1))
    1161     y = np.where(y==0, 1, y)

 ValueError: math domain error
 }}}
 The warning says "... continuing anyway, n=5", but then it crashes anyway.

-- 
Ticket URL: <http://projects.scipy.org/scipy/ticket/1492>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.


More information about the Scipy-tickets mailing list