Skip to content

Conversation

@dhardy
Copy link
Member

@dhardy dhardy commented Dec 1, 2025

  • Added a CHANGELOG.md entry

Summary

The case where p>0 but 1 - p rounds to 1 was not previously handled. Now we handle it the same as for p=0.

Fixes #34.

// NOTE: Some distributions have tests checking only that samples can be
// generated. This is redundant with vector and correctness tests.

/// An RNG which panics on first use
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the usage for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test I added needs an RNG to call sample but doesn't actually use it.

This allows asserting that the call to sample doesn't use the RNG.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(The name is dubious, but I don't think NeverRng or DummyRng is any better.)

src/geometric.rs Outdated

impl Geometric {
/// Construct a new `Geometric` with the given shape parameter `p`
/// (probability of success on each trial).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add: If p is zero or 1.0 - p rounds to 1.0 we return u64::MAX

Either make it like this or have it as implementation detail potentially subject to change.

Copy link
Member

@benjamin-lieser benjamin-lieser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@dhardy
Copy link
Member Author

dhardy commented Dec 1, 2025

I'll ignore the test failure here (not relevant to this PR).

@dhardy dhardy merged commit a681d0f into master Dec 1, 2025
13 of 14 checks passed
@dhardy dhardy deleted the push-qyzktnrnrxok branch December 1, 2025 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinite loop with Geometric::new(0.5e-16)

3 participants