Skip to content

Fix dtype casting bug in icdf function #6669

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

Merged
merged 1 commit into from
Apr 13, 2023
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
2 changes: 1 addition & 1 deletion pymc/logprob/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def icdf(
rv: TensorVariable, value: TensorLike, warn_missing_rvs: bool = True, **kwargs
) -> TensorVariable:
"""Create a graph for the inverse CDF of a Random Variable."""
value = pt.as_tensor_variable(value, dtype=rv.dtype)
value = pt.as_tensor_variable(value, dtype="floatX")
try:
return _icdf_helper(rv, value, **kwargs)
except NotImplementedError:
Expand Down
11 changes: 11 additions & 0 deletions tests/logprob/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,14 @@ def test_warn_random_found_probability_inference(func, scipy_func, test_value):
test_value
),
)


def test_icdf_discrete():
p = 0.1
value = 0.9
dist = pm.Geometric.dist(p=p)
dist_icdf = icdf(dist, value)
np.testing.assert_almost_equal(
dist_icdf.eval(),
sp.geom.ppf(value, p),
)