3535from aesara .tensor .math import tanh
3636from aesara .tensor .random .basic import (
3737 BetaRV ,
38- WeibullRV ,
3938 cauchy ,
4039 chisquare ,
4140 exponential ,
@@ -1464,7 +1463,7 @@ def dist(cls, lam, *args, **kwargs):
14641463 lam = at .as_tensor_variable (floatX (lam ))
14651464
14661465 # Aesara exponential op is parametrized in terms of mu (1/lam)
1467- return super ().dist ([at .inv (lam )], ** kwargs )
1466+ return super ().dist ([at .reciprocal (lam )], ** kwargs )
14681467
14691468 def moment (rv , size , mu ):
14701469 if not rv_size_is_none (size ):
@@ -1487,7 +1486,7 @@ def logcdf(value, mu):
14871486 -------
14881487 TensorVariable
14891488 """
1490- lam = at .inv (mu )
1489+ lam = at .reciprocal (mu )
14911490 res = at .switch (
14921491 at .lt (value , 0 ),
14931492 - np .inf ,
@@ -2313,7 +2312,7 @@ def logcdf(value, alpha, inv_beta):
23132312 -------
23142313 TensorVariable
23152314 """
2316- beta = at .inv (inv_beta )
2315+ beta = at .reciprocal (inv_beta )
23172316 res = at .switch (
23182317 at .lt (value , 0 ),
23192318 - np .inf ,
@@ -2518,8 +2517,15 @@ def logcdf(value, nu):
25182517
25192518
25202519# TODO: Remove this once logp for multiplication is working!
2521- class WeibullBetaRV (WeibullRV ):
2520+ class WeibullBetaRV (RandomVariable ):
2521+ name = "weibull"
2522+ ndim_supp = 0
25222523 ndims_params = [0 , 0 ]
2524+ dtype = "floatX"
2525+ _print_name = ("Weibull" , "\\ operatorname{Weibull}" )
2526+
2527+ def __call__ (self , alpha , beta , size = None , ** kwargs ):
2528+ return super ().__call__ (alpha , beta , size = size , ** kwargs )
25232529
25242530 @classmethod
25252531 def rng_fn (cls , rng , alpha , beta , size ) -> np .ndarray :
@@ -2615,6 +2621,16 @@ def logcdf(value, alpha, beta):
26152621
26162622 return check_parameters (res , 0 < alpha , 0 < beta , msg = "alpha > 0, beta > 0" )
26172623
2624+ def logp (value , alpha , beta ):
2625+ res = (
2626+ at .log (alpha )
2627+ - at .log (beta )
2628+ + (alpha - 1.0 ) * at .log (value / beta )
2629+ - at .pow (value / beta , alpha )
2630+ )
2631+ res = at .switch (at .ge (value , 0.0 ), res , - np .inf )
2632+ return check_parameters (res , 0 < alpha , 0 < beta , msg = "alpha > 0, beta > 0" )
2633+
26182634
26192635class HalfStudentTRV (RandomVariable ):
26202636 name = "halfstudentt"
0 commit comments