Skip to content

Commit

Permalink
Fixed: location of Z multiplier in Interpolated RV
Browse files Browse the repository at this point in the history
  • Loading branch information
kc611 committed Jun 7, 2021
1 parent 8af8844 commit 293900a
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions pymc3/distributions/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -3768,7 +3768,7 @@ def logp(value, mu, sigma):
class InterpolatedRV(RandomVariable):
name = "interpolated"
ndim_supp = 0
ndims_params = [0, 0, 0, 0]
ndims_params = [1, 1]
dtype = "floatX"
_print_name = ("Interpolated", "\\operatorname{Interpolated}")

Expand All @@ -3779,6 +3779,7 @@ def rng_fn(cls, rng, x, pdf, size=None):
Z = interp.integral(x[0], x[-1])
Z = at.as_tensor_variable(Z)

pdf = pdf / Z
cdf = interp.antiderivative()(x) / Z

p = rng.uniform(size=size)
Expand Down Expand Up @@ -3852,14 +3853,8 @@ 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])
Z = at.as_tensor_variable(Z)

pdf_points = pdf_points / Z

# cdf_points = interp.antiderivative()(x_points) / Z
x_points = at.as_tensor_variable(floatX(x_points))
pdf_points = at.as_tensor_variable(floatX(pdf_points))

# lower = at.as_tensor_variable(x_points[0])
# upper = at.as_tensor_variable(x_points[-1])
Expand Down

0 comments on commit 293900a

Please sign in to comment.