is there any algorithm in ruby on rails to generate random incremented data (especially number) for each day with different probability in each stages, in order to show a sample of line chart?
for example (the set of chart data wanted):
date, incremented random number, phase, probability
1 Jul 2018, 2, beginning, increase sharply
2 Jul 2018, 10, beginning, increase sharply
3 Jul 2018, 23, beginning, increase sharply
4 Jul 2018, 26, middle, increase moderately
5 Jul 2018, 29, middle, increase moderately
6 Jul 2018, 32, middle, increase moderately
7 Jul 2018, 34, end, increase slightly
8 Jul 2018, 35, end, increase slightly
9 Jul 2018, 35, end, increase slightly
10 Jul 2018, 36, end, increase slightly
and the requirement are:
- the number of days is defined.
- the total/sum of random number is also defined. For example, the number from the above data set totally will exactly equal to 262 which is already defined before the random number generated.
- the stages should be distributed evenly on each day.
Many thanks in advance for any suggestion or advice.
Best, Randy
Aucun commentaire:
Enregistrer un commentaire