Say I have 100 records, and I want to mock out the created_at
date so it fits on some curve. Is there a library to do that, or what formula could I use? I think this is along the same track:
Generate Random Numbers with Probabilistic Distribution
I don't know much about how they are classified in mathematics, but I'm looking at things like:
- bell curve
- logarithmic (typical biology/evolution) curve? ...
Just looking for some formulas in code so I can say this:
- Given 100 records, a timespan of
1.week
, and an interval of12.hours
- set
created_at
for each record such that it fits, roughly, tocurve
Thanks so much!
Update
I found this forum post about ruby algorithms, which led me to rsruby, an R/Ruby bridge, but that seems like too much.
Update 2
I wrote this little snippet trying out the gsl
library, getting there...
Generate test data in Rails where created_at falls along a Statistical Distribution
You can generate UNIX timestamps which are really just integers. First figure out when you want to start, for example now:
Find out when the end of your interval should be (say 1 week later):
Ruby uses this algorithm to generate random numbers. It is almost uniform. Then generate random numbers between the two:
Then convert that back to a date:
This looks promising as well: http://rb-gsl.rubyforge.org/files/rdoc/randist_rdoc.html
And this too: http://rb-gsl.rubyforge.org/files/rdoc/rng_rdoc.html