Skip to content

Move slightly duplicated RVs to PyTensor #6502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
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
28 changes: 2 additions & 26 deletions pymc/distributions/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
from pytensor.tensor.math import tanh
from pytensor.tensor.random.basic import (
BetaRV,
StudentTRV,
WaldRV,
cauchy,
chisquare,
exponential,
Expand Down Expand Up @@ -171,7 +173,6 @@ def bounded_cont_transform(op, rv, bound_args_indices=None):
raise ValueError(f"Must specify bound_args_indices for {op} bounded distribution")

def transform_params(*args):

lower, upper = None, None
if bound_args_indices[0] is not None:
lower = args[bound_args_indices[0]]
Expand Down Expand Up @@ -837,18 +838,6 @@ def logcdf(value, loc, sigma):
)


class WaldRV(RandomVariable):
name = "wald"
ndim_supp = 0
ndims_params = [0, 0, 0]
dtype = "floatX"
_print_name = ("Wald", "\\operatorname{Wald}")

@classmethod
def rng_fn(cls, rng, mu, lam, alpha, size) -> np.ndarray:
return np.asarray(rng.wald(mu, lam, size=size) + alpha)


wald = WaldRV()


Expand Down Expand Up @@ -1660,18 +1649,6 @@ def logcdf(value, mu, sigma):
Lognormal = LogNormal


class StudentTRV(RandomVariable):
name = "studentt"
ndim_supp = 0
ndims_params = [0, 0, 0]
dtype = "floatX"
_print_name = ("StudentT", "\\operatorname{StudentT}")

@classmethod
def rng_fn(cls, rng, nu, mu, sigma, size=None) -> np.ndarray:
return np.asarray(stats.t.rvs(nu, mu, sigma, size=size, random_state=rng))


studentt = StudentTRV()


Expand Down Expand Up @@ -3474,7 +3451,6 @@ class Interpolated(BoundedContinuous):

@classmethod
def dist(cls, x_points, pdf_points, *args, **kwargs):

interp = InterpolatedUnivariateSpline(x_points, pdf_points, k=1, ext="zeros")

Z = interp.integral(x_points[0], x_points[-1])
Expand Down