35
35
from aesara .tensor .math import tanh
36
36
from aesara .tensor .random .basic import (
37
37
BetaRV ,
38
- WeibullRV ,
39
38
cauchy ,
40
39
chisquare ,
41
40
exponential ,
@@ -1464,7 +1463,7 @@ def dist(cls, lam, *args, **kwargs):
1464
1463
lam = at .as_tensor_variable (floatX (lam ))
1465
1464
1466
1465
# 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 )
1468
1467
1469
1468
def moment (rv , size , mu ):
1470
1469
if not rv_size_is_none (size ):
@@ -1487,7 +1486,7 @@ def logcdf(value, mu):
1487
1486
-------
1488
1487
TensorVariable
1489
1488
"""
1490
- lam = at .inv (mu )
1489
+ lam = at .reciprocal (mu )
1491
1490
res = at .switch (
1492
1491
at .lt (value , 0 ),
1493
1492
- np .inf ,
@@ -2313,7 +2312,7 @@ def logcdf(value, alpha, inv_beta):
2313
2312
-------
2314
2313
TensorVariable
2315
2314
"""
2316
- beta = at .inv (inv_beta )
2315
+ beta = at .reciprocal (inv_beta )
2317
2316
res = at .switch (
2318
2317
at .lt (value , 0 ),
2319
2318
- np .inf ,
@@ -2518,8 +2517,15 @@ def logcdf(value, nu):
2518
2517
2519
2518
2520
2519
# TODO: Remove this once logp for multiplication is working!
2521
- class WeibullBetaRV (WeibullRV ):
2520
+ class WeibullBetaRV (RandomVariable ):
2521
+ name = "weibull"
2522
+ ndim_supp = 0
2522
2523
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 )
2523
2529
2524
2530
@classmethod
2525
2531
def rng_fn (cls , rng , alpha , beta , size ) -> np .ndarray :
@@ -2615,6 +2621,16 @@ def logcdf(value, alpha, beta):
2615
2621
2616
2622
return check_parameters (res , 0 < alpha , 0 < beta , msg = "alpha > 0, beta > 0" )
2617
2623
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
+
2618
2634
2619
2635
class HalfStudentTRV (RandomVariable ):
2620
2636
name = "halfstudentt"
0 commit comments