Skip to content

remove DiscreteUniform factory method on Uniform. Fix Implementation - #170

Merged
marcelluethi merged 1 commit into
dimwit-dev:mainfrom
marcelluethi:uniform-constructor
Sep 28, 2026
Merged

marcelluethi merged 1 commit into
dimwit-dev:mainfrom
marcelluethi:uniform-constructor

Conversation

@marcelluethi

Copy link
Copy Markdown
Contributor

The Unifom distribution has a factory method that when 2 Ints are provided, creates a DiscreteUniform distribution instead of a Uniform distribution. This is confusing and also leads to unexpected behaviors when constructing uniform distributions. Therefore this constructor is removed.

This commit also adds tests for DiscreteUniform and fixes a bug in the implementation that was discovered when adding the tests. It turns out that jax.scipy.stats.randint does not exist and therefore cannot be used to compute the logpmf. The solution is to simply compute the logprob ourselves, which is trivial for the discrete uniform distribution.

The Unifom distribution has a factory method that when 2 Ints are provided, creates a DiscreteUniform distribution instead of a Uniform distribution. This is confusing and also leads to unexpected behaviors when constructing uniform distributions. Therefore this constructor is removed.

This commit also adds tests for the DiscreteUniform and fixes
a bug in the implementation that was discovered when adding the tests.

@benikm91 benikm91 left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I agree that the constructor is confusing on Uniform and must be removed.

Thanks for adding the tests and fixing the bug!

@marcelluethi
marcelluethi merged commit b2f23b5 into dimwit-dev:main Sep 28, 2026
1 check passed
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.

2 participants