Skip to content

Commit

Permalink
Merge pull request #60 from michaeldickens/fix-pareto-sample
Browse files Browse the repository at this point in the history
Fix pareto_sample to sample from Pareto dist instead of Lomax
  • Loading branch information
peterhurford authored Dec 18, 2023
2 parents 04a45ec + 116de90 commit eeb215c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion squigglepy/samplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,9 @@ def pareto_sample(shape, samples=1):
>>> pareto_sample(1)
10.069666324736094
"""
return _simplify(_get_rng().pareto(shape, samples))
# Add 1 because Numpy's "pareto" sampler actually samples from a Lomax
# distribution
return _simplify(_get_rng().pareto(shape, samples) + 1)


def uniform_sample(low, high, samples=1):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_samplers.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def test_sample_gamma_passes_lclip_rclip():

@patch.object(samplers, "_get_rng", Mock(return_value=FakeRNG()))
def test_sample_pareto_default():
assert sample(pareto(10)) == 10
assert sample(pareto(10)) == 11


@patch.object(samplers, "_get_rng", Mock(return_value=FakeRNG()))
Expand Down

0 comments on commit eeb215c

Please sign in to comment.