TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Generating Random Numbers from a Specific Distribution by Inverting the CDF

66 pointsby Atrix256almost 8 years ago

5 comments

pashalmost 8 years ago
Statisticians call this <i>inverse transform sampling</i> [0]. The dual result, that Y = F(X) is uniformly distributed for F the cdf of any random variable X, is called the <i>probability integral transform</i> [1].<p>0. <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Inverse_transform_sampling" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Inverse_transform_sampling</a><p>1. <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Probability_integral_transform" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Probability_integral_transform</a>
评论 #14944943 未加载
todd8almost 8 years ago
For those needing more detail on generating numbers from a specific distribution there is Knuth&#x27;s <i>The Art of Computer Programming</i>, Vol. 2 Seminumerical Algorithms, see section 3.4 <i>Other types of random quantities</i>. Special treatment is given for many distributions: normal, exponential, gamma, chi-squared, f-distribution, binomial, Poisson, along with discussion of general methods. Although there have been more recent advances in the generation of high-quality, high-speed generation of uniformly distributed random numbers, Knuth covers a whole range of issues related to pseudorandom number generation.
gautamdivgialmost 8 years ago
I used inverse transform sampling extensively in my thesis. I used it for fitting distributions to data (new methods)and similarity analysis of CDF&#x27;s. In the software engineering field in am frequently appalled by how often basic probability techniques are ignored in favor of just the &quot;mean&quot; and &quot;std. deviation&quot;.
评论 #14946651 未加载
评论 #14945303 未加载
pettersalmost 8 years ago
I&#x27;m sorry, but this post is not a very good explanation. Here&#x27;s why we should invert the CDF:<p>&gt; The issue is that if we flip x and y’s in a PDF, there would be multiple y values corresponding to the same x. This isn’t true in a CDF.<p>Surely there must be a better reason to invert the CDF than that it&#x27;s possible?<p>Any textbook will explain this much, much better.
评论 #14947646 未加载
procedural_lovealmost 8 years ago
This is awesome! I wanted to do this for a procedural generation algorithm during a game jam but didn&#x27;t have the time to figure it out.