Programming => General => Topic started by: minesadorada on July 22, 2019, 08:14:42 pm
Title: Help needed for an algorithm
Post by: minesadorada on July 22, 2019, 08:14:42 pm
I want to generate 1000 random numbers with a configurable bias. It is for an app I am planning to write (for fun) - the generator will be a class of course.
Scenario 1: 50% numbers over 0.5. - Easy - just use Random()
Scenario 2: x% numbers over 0.5 - a general algorithm
There are some awesome programmers on this forum that can help me I am sure. I can't come up with efficient code for scenario(2) on my own. I promise all that this is not homework - I left school 50 years ago!
Title: Re: Help needed for an algorithm
Post by: Thaddy on July 22, 2019, 08:39:03 pm
Has already been done for us: https://wiki.freepascal.org/Generating_Random_Numbers#Exponential_Distribution (and others, with slightly differing implementations). I think for your purpose this is a good match but read the wiki entry carefully: there are more gems there, like Erlang.
Title: Re: Help needed for an algorithm
Post by: winni on July 22, 2019, 08:43:09 pm