1 min readFeb 23, 2019
Thank you for asking Dormando — very good manners! Any Java in this article I dedicate with the Unlicense license. In other words: do what you like with the code, no need to attribute me, and don’t blame me if it doesn’t work!
Bear in mind that this article was meant as instructive, not as production code. An excellent free Java version (which I use myself) is in the Apache Commons Math library. It can use either an inversion technique (super slow!), or rejection sampling. It is significantly more sophisticated and stable than my mini example, so I would highly recommend using that instead of the code above.