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

Explain truncated gumbel sampling #5

Open
textstorm opened this issue Jun 8, 2018 · 1 comment
Open

Explain truncated gumbel sampling #5

textstorm opened this issue Jun 8, 2018 · 1 comment

Comments

@textstorm
Copy link

I didn't know why truncated gumbel can sampled in this way
return -tf.log(EPSILON + tf.exp(-gumbel) + tf.exp(-truncation))
can u describe it?

@Bonnevie
Copy link
Owner

Bonnevie commented Jun 8, 2018

Yeah, it's not super obvious. I borrowed the trick from here, but they don't demonstrate it either. But it's actually not too hard to show. Remember that an easy way to sample is to use an inverse transform sampler, where you map uniform noise through the inverse CDF of the desired distribution. So if we can find the CDF and invert it, we have a sampler. All you then need to do is to grab the CDF of a truncated distribution from Wikipedia, plug in the Gumbel CDF and invert it.
Since the sampler above assumes gumbel noise, you will also need to map the gumbel noise through its CDF to get uniform noise (running the original Gumbel inverse transform sampler in reverse), which means that the final expression has the form
InverseTruncatedCDF(CDF(gumbel)).

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

2 participants