Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suspicious implementation of sampling from categorical for cluster assignments #55

Open
riastradh-probcomp opened this issue Sep 24, 2015 · 2 comments
Milestone

Comments

@riastradh-probcomp
Copy link
Contributor

simple_predictive_sample_unobserved (

probs = numpy.exp(cluster_logps)
probs /= sum(probs)
draw = numpy.nonzero(numpy.random.multinomial(1, probs))[0][0]
) does this:

        probs = numpy.exp(cluster_logps)
        probs /= sum(probs)
        draw = numpy.nonzero(numpy.random.multinomial(1, probs))[0][0]
@axch
Copy link
Contributor

axch commented Sep 24, 2015

Which is sad, because that operation is called sampleLogCategorical (in the Venture codebase), and it really should subtract off the maximum of the cluster_logps before starting to exponentiate them, lest loss of precision lead to bad results or crashes.

Separately, it probably shouldn't use numpy's ambient prng for its entropy, but that feels like a more involved problem.

@riastradh-probcomp
Copy link
Contributor Author

Use of numpy's entropy is now issue #56.

@raxraxraxraxrax raxraxraxraxrax added this to the analysis milestone Dec 22, 2015
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

No branches or pull requests

3 participants