[erlang-questions] On OTP rand module difference between OTP 19 and OTP 20
Raimo Niskanen
<>
Thu Aug 31 14:30:08 CEST 2017
On Thu, Aug 31, 2017 at 10:34:16AM +1200, Richard A. O'Keefe wrote:
>
>
> On 30/08/17 6:42 PM, Raimo Niskanen wrote:
> > On Wed, Aug 30, 2017 at 11:44:57AM +1200, Richard A. O'Keefe wrote:
>
> >> There are applications of random numbers for which it is important
> >> that 0 never be returned. Of course, nothing stops me writing
> >
> > What kind of applications? I would like to get a grip on how needed this
> > function is?
>
> I'll give you just one example. There are two ways I know to generate
> normally distributed random numbers. One of them goes like this:
>
> sqrt(-2 * ln(randnz()) * cos(pi * random())
>
> where random() is in [0,1) but randnz() must be in (0,1).
>
> OK, I'll give you another example. This is part of an algorithm for
> generating gamma variates, one of the best known.
>
> U <- random()
> if U <= r then
> z <- -ln(U/r)
> else
> z <- ln(random()/lambda)
> end
>
> You will notice that both of the calls to ln will go wrong if
> random() can return 0.
>
> These aren't the only examples, but I have an appointment.
Thank you!
Should I make a pull request of this?
https://github.com/erlang/otp/compare/OTP-20.0...RaimoNiskanen:raimo/stdlib/rand-uniformNZ
Is the name uniformNZ good enough?
Are uniform floats complete enough with this addition?
--
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions
mailing list