[Scipy-tickets] [SciPy] #1882: Computing variance of non-central t-distribution gives error

SciPy Trac scipy-tickets@scipy....
Fri Mar 29 10:35:36 CDT 2013


#1882: Computing variance of non-central t-distribution gives error
--------------------+-------------------------------------------------------
 Reporter:  Sytse   |       Owner:  somebody   
     Type:  defect  |      Status:  new        
 Priority:  normal  |   Milestone:  Unscheduled
Component:  Other   |     Version:  0.11.0     
 Keywords:          |  
--------------------+-------------------------------------------------------
 The error messages lead to line 1490: if np.isinf(mu).[[BR]]
 My ad-hoc remedy was to further indent the lines 1490, 1491 and 1492, but
 I am not certain that this is the real solution.

 Here is the code and the error messages:

 In [1]: import scipy.stats.distributions as dist

 In [2]: nt=dist.nct(10,1)

 In [3]: print(nt.var())
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)
 /home/sytse/Dropbox/Projects/Python/PyQRS/<ipython-input-5-082a4d0f15ce>
 in <module>()
 ----> 1 print(nt.var())

 /usr/lib/python3/dist-packages/scipy/stats/distributions.py in var(self)
     365
     366     def var(self):
 --> 367         return self.dist.var(*self.args, **self.kwds)
     368
     369     def std(self):

 /usr/lib/python3/dist-packages/scipy/stats/distributions.py in var(self,
 *args, **kwds)
     665         """
     666         kwds['moments'] = 'v'
 --> 667         res = self.stats(*args, **kwds)
     668         if isinstance(res, ndarray) and res.ndim == 0:
     669             return res[()]

 /usr/lib/python3/dist-packages/scipy/stats/distributions.py in stats(self,
 *args, **kwds)
    1488                         mu = self._munp(1.0,*goodargs)
    1489                     mu2 = mu2p - mu*mu
 -> 1490                 if np.isinf(mu):
    1491                         #if mean is inf then var is also inf

    1492                     mu2 = np.inf

 TypeError: ufunc 'isinf' not supported for the input types, and the inputs
 could not be safely coerced to any supported types according to the
 casting rule 'safe'

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


More information about the Scipy-tickets mailing list