@@ -1035,16 +1035,20 @@ def _sf(self, x, a, b):
1035
1035
1036
1036
def _ppf (self , p , a , b ):
1037
1037
p , a , b = np .broadcast_arrays (p , a , b )
1038
- # by default, compute compute the ppf by solving the following:
1038
+ # By default, compute the ppf by solving the following:
1039
1039
# p = beta._cdf(x/(1+x), a, b). This implies x = r/(1-r) with
1040
1040
# r = beta._ppf(p, a, b). This can cause numerical issues if r is
1041
- # very close to 1. in that case, invert the alternative expression of
1041
+ # very close to 1. In that case, invert the alternative expression of
1042
1042
# the cdf: p = beta._sf(1/(1+x), b, a).
1043
1043
r = stats .beta ._ppf (p , a , b )
1044
1044
with np .errstate (divide = 'ignore' ):
1045
1045
out = r / (1 - r )
1046
- i = (r > 0.9999 )
1047
- out [i ] = 1 / stats .beta ._isf (p [i ], b [i ], a [i ]) - 1
1046
+ rnear1 = r > 0.9999
1047
+ if np .isscalar (r ):
1048
+ if rnear1 :
1049
+ out = 1 / stats .beta ._isf (p , b , a ) - 1
1050
+ else :
1051
+ out [rnear1 ] = 1 / stats .beta ._isf (p [rnear1 ], b [rnear1 ], a [rnear1 ]) - 1
1048
1052
return out
1049
1053
1050
1054
def _munp (self , n , a , b ):
@@ -4880,7 +4884,7 @@ def _stats(self, mu):
4880
4884
def fit (self , data , * args , ** kwds ):
4881
4885
method = kwds .get ('method' , 'mle' )
4882
4886
4883
- if (isinstance (data , CensoredData ) or type (self ) == wald_gen
4887
+ if (isinstance (data , CensoredData ) or isinstance (self , wald_gen )
4884
4888
or method .lower () == 'mm' ):
4885
4889
return super ().fit (data , * args , ** kwds )
4886
4890
0 commit comments