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 ?
Asked
Active
Viewed 2,276 times
2
-
2Time for you to write a gem :) – Jason Kim Aug 20 '13 at 22:27
-
3possible duplicate of [Code to generate Gaussian (normally distributed) random numbers in Ruby](http://stackoverflow.com/questions/5825680/code-to-generate-gaussian-normally-distributed-random-numbers-in-ruby) – Oliver Charlesworth Aug 20 '13 at 22:28
-
1http://rubygems.org/gems/distribution – Oliver Charlesworth Aug 20 '13 at 22:30
1 Answers
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