Hello everyone, I need to implement a random generator in C# that generates random numbers according to a probability distribution function, e.g. Gaussian bell.

For example, I have a range of values from 10 to 45 and I need to randomly generate numbers from this range. Additionally, I have a gaussian bell function with its peek on 18. Now I am expecting the random generator to generate values out of this range with 18 having the highest probability to apear and the rest of values, depending on their dsitance from 18 and the probability defined by the Gaussian bell appear with less probability. Furthermore, I'm expecting values like 10 or 45 to appear rarely, as they are on the extends of my range!!!

I have googled a lot but I haven't found anything to help me. Also, I have tried to implement a workaround by using the generated random value between 0.0 and 1.0 and then according to a fixed probability, assigning each random value to a sub-range of my values:

myRange = [0 ~ 40] // probility peek is on 20

p = rand.Next() // e.g. 0.328172if (p < 0.1)

Output rand.Next (0 ~ 15) or rand.Next (25 ~ 40); //probability 10%

if (p < 0.5)

Output rand.Next (15 ~ 18) or rand.Next (22 ~ 25); //probability 40%

if(p < 1.0)

Output rand.Next (18 ~ 22) //probability 50%But this is not working good at all. It is producing some values, but its not smooth enough for my purposes. I need to generate Synthetic Data on user activities like TV_On, use_WC, etc. based on predefined probabilities.

Please help me. Any help, suggestion, theory, or evern recommendation on online materials would greatly help.

I appreciate your time and care,

Greetings from Ferri

Ask Your Question

Weekly Poll

Do you think Google should sell budget phones in the US?

Discuss in The Lounge

Poll History