Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pytensor_distributions/beta.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytensor.tensor as pt
from pytensor.tensor.math import betaincinv
from pytensor.tensor.special import betaln
from pytensor.tensor.xlogx import xlogy0
from pytensor.tensor.special import betaln, xlogy

from pytensor_distributions.helper import ppf_bounds_cont
from pytensor_distributions.lmoments import _lmoments
Expand Down Expand Up @@ -120,8 +119,8 @@ def logpdf(x, alpha, beta):
return pt.switch(
pt.bitwise_or(pt.lt(x, 0), pt.gt(x, 1)),
-pt.inf,
(xlogy0((alpha - 1), x) + xlogy0((beta - 1), 1 - x))
- (xlogy0((alpha + beta - 1), 1) + betaln(alpha, beta)),
(xlogy((alpha - 1), x) + xlogy((beta - 1), 1 - x))
- (xlogy((alpha + beta - 1), 1) + betaln(alpha, beta)),
)


Expand Down
7 changes: 3 additions & 4 deletions pytensor_distributions/betascaled.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytensor.tensor as pt
from pytensor.tensor.math import betaincinv
from pytensor.tensor.special import betaln
from pytensor.tensor.xlogx import xlogy0
from pytensor.tensor.special import betaln, xlogy

from pytensor_distributions.helper import ppf_bounds_cont
from pytensor_distributions.lmoments import _lmoments
Expand Down Expand Up @@ -124,8 +123,8 @@ def logpdf(x, alpha, beta, lower, upper):
return pt.switch(
pt.bitwise_or(pt.lt(x, lower), pt.gt(x, upper)),
-pt.inf,
(xlogy0((alpha - 1), (x - lower)) + xlogy0((beta - 1), (upper - x)))
- (xlogy0((alpha + beta - 1), (upper - lower)) + betaln(alpha, beta)),
(xlogy((alpha - 1), (x - lower)) + xlogy((beta - 1), (upper - x)))
- (xlogy((alpha + beta - 1), (upper - lower)) + betaln(alpha, beta)),
)


Expand Down
4 changes: 2 additions & 2 deletions pytensor_distributions/binomial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytensor.tensor as pt
from pytensor.tensor.xlogx import xlogy0
from pytensor.tensor.special import xlogy

from pytensor_distributions.helper import cdf_bounds, discrete_entropy
from pytensor_distributions.lmoments import _lmoments
Expand Down Expand Up @@ -87,7 +87,7 @@ def logpdf(x, n, p):
pt.gammaln(n + 1)
- pt.gammaln(x + 1)
- pt.gammaln(n - x + 1)
+ xlogy0(x, p)
+ xlogy(x, p)
+ (n - x) * pt.log1p(-p),
)

Expand Down
4 changes: 2 additions & 2 deletions pytensor_distributions/chisquared.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytensor.tensor as pt
from pytensor.tensor.xlogx import xlogy0
from pytensor.tensor.special import xlogy

from pytensor_distributions.helper import cdf_bounds, ppf_bounds_cont
from pytensor_distributions.lmoments import _lmoments
Expand Down Expand Up @@ -87,7 +87,7 @@ def logpdf(x, nu):
return pt.switch(
pt.lt(x, 0),
-pt.inf,
xlogy0(nu / 2 - 1, x) - x / 2 - pt.gammaln(nu / 2) - (nu * pt.log(2)) / 2,
xlogy(nu / 2 - 1, x) - x / 2 - pt.gammaln(nu / 2) - (nu * pt.log(2)) / 2,
)


Expand Down
5 changes: 2 additions & 3 deletions pytensor_distributions/kumaraswamy.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytensor.tensor as pt
from pytensor.tensor.special import betaln
from pytensor.tensor.xlogx import xlogy0
from pytensor.tensor.special import betaln, xlogy

from pytensor_distributions.helper import cdf_bounds, ppf_bounds_cont, sf_bounds

Expand Down Expand Up @@ -112,7 +111,7 @@ def logpdf(x, a, b):
return pt.switch(
pt.bitwise_or(pt.le(x, 0), pt.ge(x, 1)),
-pt.inf,
pt.log(a * b) + xlogy0(a - 1, x) + xlogy0(b - 1, 1 - x**a),
pt.log(a * b) + xlogy(a - 1, x) + xlogy(b - 1, 1 - x**a),
)


Expand Down
4 changes: 2 additions & 2 deletions pytensor_distributions/negativebinomial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytensor.tensor as pt
from pytensor.tensor.xlogx import xlogy0
from pytensor.tensor.special import xlogy

from pytensor_distributions.helper import cdf_bounds, discrete_entropy, sf_bounds
from pytensor_distributions.lmoments import _lmoments
Expand Down Expand Up @@ -88,7 +88,7 @@ def logpdf(x, n, p):
return pt.switch(
pt.lt(x, 0),
-pt.inf,
pt.gammaln(x + n) - pt.gammaln(n) - pt.gammaln(x + 1) + xlogy0(n, p) + xlogy0(x, 1 - p),
pt.gammaln(x + n) - pt.gammaln(n) - pt.gammaln(x + 1) + xlogy(n, p) + xlogy(x, 1 - p),
)


Expand Down
4 changes: 2 additions & 2 deletions pytensor_distributions/poisson.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytensor.tensor as pt
from pytensor.tensor.xlogx import xlogy0
from pytensor.tensor.special import xlogy

from pytensor_distributions.helper import cdf_bounds, discrete_entropy, sf_bounds
from pytensor_distributions.lmoments import _lmoments
Expand Down Expand Up @@ -85,7 +85,7 @@ def rvs(mu, size=None, random_state=None):


def logpdf(x, mu):
return xlogy0(x, mu) - pt.gammaln(x + 1) - mu
return xlogy(x, mu) - pt.gammaln(x + 1) - mu


def logcdf(x, mu):
Expand Down
5 changes: 2 additions & 3 deletions pytensor_distributions/weibull.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytensor.tensor as pt
from pytensor.tensor.special import gamma
from pytensor.tensor.xlogx import xlogy0
from pytensor.tensor.special import gamma, xlogy

from pytensor_distributions.helper import ppf_bounds_cont

Expand Down Expand Up @@ -106,7 +105,7 @@ def logpdf(x, alpha, beta):
return pt.switch(
pt.lt(x, 0),
-pt.inf,
pt.log(alpha / beta) + xlogy0(alpha - 1, x / beta) - (x / beta) ** alpha,
pt.log(alpha / beta) + xlogy(alpha - 1, x / beta) - (x / beta) ** alpha,
)


Expand Down
Loading