I'm very new to Scala and trying to write a UDF that will allow me to draw a sample from the binomial distribution given parameters n and p. It seems like I could use https://www.scala-lang.org/api/2.8.2/scala/util/Random.html to generate random Bernoulli trials with parameter p (similar to what is described here Spark - Random Number Generation) and sum them together. However, it seems inefficient to do it this way when n is large. I could also generate gaussian trials from the above as an approximation, but would much prefer true binomial if possible because p is very close to 1 in some cases for me.
Is there a Scala library that I can just add somehow to get samples from the binomial distribution?
Aucun commentaire:
Enregistrer un commentaire