Ok this is getting me confused.
I need to creat e random number. usually not an issue. I need to be able to pass 3 paramaters though
a minimum, a maximum and a most likely.
the further away from the most likely you get the less chance that number has of actually showing.
Any idea on how I can accomplish this or even any tips?
Loading
VulpesPosted Nov 26, 2012, 10:09 AM
Here's some code to do this (.NET 4.0 or later) which uses integer arithmetic throughout for simplicity (just change to double if you need random decimal numbers). The code generates 10000 random numbers between 1 and 9 with a most likely value of 5.
Default weights of 20 are used for the minimum and maximum values relative to a weight of 100 for the most likely number:
A typical result from running this program:
This compares with the 'expected' values of:
1 frequency = 400