how to generate an array of number in a skewed normal distribution? [duplicate]
Possible Duplicate:
generating random numbers from skewed normal distribution
i expect a long array containing integers [3,7,7,7,7,1....]
but the overall distribution should be skewed and normal.
using random() generates a uniform distribution.....
If you are looking for just a few integers as your random numbers, then divide the range of random numbers accordingly.
For example, if your random function returns a number from zero to 1, and you want "3" to have a frequency of 10%, and "7" a frequency of 40%, you could say something like
uneven_rand()
{
-
r = rand();
if (r < 0.1) return 3; // covers range from 0 to 0.1
if (r < 0.5) return 7; // Covers range from 0.1 to 0.5
etc...
精彩评论