@@ -1846,7 +1846,7 @@ class dpareto_lognorm_gen(rv_continuous):
1846
1846
\left( R(y_1) + R(y_2) \right)
1847
1847
1848
1848
where :math:`R(t) = \frac{1 - \Phi(t)}{\phi(t)}`,
1849
- :math:`phi` and :math:`Phi` are the normal PDF and CDF, respectively,
1849
+ :math:`\ phi` and :math:`\ Phi` are the normal PDF and CDF, respectively,
1850
1850
:math:`y_1 = \alpha \sigma - \frac{\log x - \mu}{\sigma}`,
1851
1851
and :math:`y_2 = \beta \sigma + \frac{\log x - \mu}{\sigma}`
1852
1852
for real numbers :math:`x` and :math:`\mu`, :math:`\sigma > 0`,
@@ -1923,20 +1923,24 @@ def _logpdf(self, x, u, s, a, b):
1923
1923
return out [()]
1924
1924
1925
1925
def _logcdf (self , x , u , s , a , b ):
1926
- log_y , m = np .log (x ), u # compare against [1] Eq. 2
1927
- z = (log_y - m ) / s
1928
- x1 = a * s - z
1929
- x2 = b * s + z
1930
- t1 = self ._logPhi (z )
1931
- t2 = self ._logphi (z )
1932
- t3 = (np .log (b ) + self ._logR (x1 ))
1933
- t4 = (np .log (a ) + self ._logR (x2 ))
1934
- t1 , t2 , t3 , t4 , one = np .broadcast_arrays (t1 , t2 , t3 , t4 , 1 )
1935
- # t3 can be smaller than t4, so we have to consider log of negative number
1936
- # This would be much simpler, but `return_sign` is available, so use it?
1937
- # t5 = sc.logsumexp([t3, t4 + np.pi*1j])
1938
- t5 , sign = sc .logsumexp ([t3 , t4 ], b = [one , - one ], axis = 0 , return_sign = True )
1939
- return sc .logsumexp ([t1 , t2 + t5 - np .log (a + b )], b = [one , - one * sign ], axis = 0 )
1926
+ with np .errstate (invalid = 'ignore' , divide = 'ignore' ):
1927
+ log_y , m = np .log (x ), u # compare against [1] Eq. 2
1928
+ z = (log_y - m ) / s
1929
+ x1 = a * s - z
1930
+ x2 = b * s + z
1931
+ t1 = self ._logPhi (z )
1932
+ t2 = self ._logphi (z )
1933
+ t3 = (np .log (b ) + self ._logR (x1 ))
1934
+ t4 = (np .log (a ) + self ._logR (x2 ))
1935
+ t1 , t2 , t3 , t4 , one = np .broadcast_arrays (t1 , t2 , t3 , t4 , 1 )
1936
+ # t3 can be smaller than t4, so we have to consider log of negative number
1937
+ # This would be much simpler, but `return_sign` is available, so use it?
1938
+ # t5 = sc.logsumexp([t3, t4 + np.pi*1j])
1939
+ t5 , sign = sc .logsumexp ([t3 , t4 ], b = [one , - one ], axis = 0 , return_sign = True )
1940
+ temp = [t1 , t2 + t5 - np .log (a + b )]
1941
+ out = np .asarray (sc .logsumexp (temp , b = [one , - one * sign ], axis = 0 ))
1942
+ out [x == 0 ] = - np .inf
1943
+ return out [()]
1940
1944
1941
1945
def _logsf (self , x , u , s , a , b ):
1942
1946
return _log1mexp (self ._logcdf (x , u , s , a , b ))
0 commit comments