Skip to content

Samples are outside the support for DiscreteUniform distribution #1834

@Deathn0t

Description

@Deathn0t

Hello,

I noticed that samples have value outside the support for DiscreteUniform distribution. Here is a simple reproducible example:

import jax.random
import numpyro

import numpyro.distributions as dist

from numpyro.infer import HMC, MCMC, MixedHMC


def model():
    x = numpyro.sample("x", dist.DiscreteUniform(1, 2))


num_samples = 10
kernel = HMC(model, trajectory_length=1.2)
kernel = MixedHMC(kernel, num_discrete_updates=20)
mcmc = MCMC(kernel, num_warmup=1000, num_samples=num_samples, progress_bar=False)
key = jax.random.PRNGKey(0)
mcmc.run(key)
samples = mcmc.get_samples()

print(samples)

Which outputs:

{'x': Array([1, 1, 0, 0, 0, 0, 0, 0, 0, 1], dtype=int32)}

I was expecting values of x to be in [1,2].

Am I using it wrongly or is it a real bug?

Thank you very much for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions