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…..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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…
}