2

I've been looking on Google/stackoverflow for a couple of hours and I can't find a way (or even a gem) to generate normally distributed random variables using ruby on rails. It's a bit frustrating..! Any idea ?

titibouboul
  • 1,348
  • 3
  • 16
  • 30

1 Answers1

2

Thanks for the help in comments. Oli is right, I found the answer in that answer :

https://stackoverflow.com/a/8205982/2576033

Using rubystats gem - "a port of the statistics libraries from PHPMath" (pure ruby), you can generate normally distributed variables, easily and in a nice way :

gen = Rubystats::NormalDistribution.new(mean, sd)
gen.rng               # a single random sample
gen.rng(100)          # 100 random samples
Community
  • 1
  • 1
titibouboul
  • 1,348
  • 3
  • 16
  • 30