Skip to content

Conversation

@helmutsimon
Copy link
Contributor

Useful for categorical distribution with a very large support set (i.e. large value of k) and all probabilities equal.

@twiecki
Copy link
Member

twiecki commented May 6, 2019

=================================== FAILURES ===================================
___________________ TestDiscreteUniform.test_DiscreteUniform ___________________
self = <pymc3.tests.test_step.TestDiscreteUniform object at 0x7f9bf338ba20>
lower = 0, upper = 200000000, obs = <TensorType(int64, scalar)>, draws = 20000
    def test_DiscreteUniform(self, lower=0, upper=200000000,
                             obs=5000000, draws=20000):
        """Test that DiscreteUniform distribution can use
         CategoricalGibbsMetropolis step method."""
        obs = theano.shared(obs)
        with Model() as model2:
    
            x = DiscreteUniform('x', lower, upper - 1)
            sfs_obs = Poisson('sfs_obs', mu=x, observed=obs)
    
        with model2:
    
            step = CategoricalGibbsMetropolis([x])
>           trace = sample(draws, tune=0, step=step)
pymc3/tests/test_step.py:1069: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pymc3/sampling.py:452: in sample
    trace = _sample_many(**sample_args)
pymc3/sampling.py:498: in _sample_many
    step=step, random_seed=random_seed[i], **kwargs)
pymc3/sampling.py:540: in _sample
    for it, strace in enumerate(sampling):
../../../miniconda3/envs/testenv/lib/python3.6/site-packages/tqdm/_tqdm.py:1022: in __iter__
    for obj in iterable:
pymc3/sampling.py:635: in _iter_sample
    point = step.step(point)
pymc3/step_methods/arraystep.py:142: in step
    apoint = self.astep(bij.map(point), *inputs)
pymc3/step_methods/metropolis.py:444: in astep_unif
    curr_val, q[dim] = q[dim], sample_except(k, q[dim])
pymc3/step_methods/metropolis.py:620: in sample_except
    candidate = nr.choice(limit - 1)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
>   ???
E   ValueError: 'a' must be greater than 0 unless no samples are taken
mtrand.pyx:1119: ValueError

@helmutsimon
Copy link
Contributor Author

What this error appears to require is that the 'k' parameter in the CategoricalGibbsMetropolis step method, which is the size of the set over which the particular categorical distribution is defined, is zero for the test case. Since k is defined as the parameter 'upper' in the case of a DiscreteUniform distribution, I am unable to see how this could occur with the test cases I supplied. The error does not occur when I run the test_step tests in my local fork of the repository.

@twiecki
Copy link
Member

twiecki commented Jul 27, 2020

Closing due to inactivity.

@twiecki twiecki closed this Jul 27, 2020
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