Computing.Net > Forums > Programming > Random Numbers according to a pdf

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Random Numbers according to a pdf

Reply to Message Icon

Name: Ferri
Date: October 27, 2009 at 08:17:28 Pacific
OS: Windows XP
Subcategory: General
Comment:

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.328172

if (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



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: October 29, 2009 at 07:32:37 Pacific
Reply:
0
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Random Numbers according to a pdf

Random numbers in a loop www.computing.net/answers/programming/random-numbers-in-a-loop/8730.html

Batch rename according to a list www.computing.net/answers/programming/batch-rename-according-to-a-list/18556.html

Unique random numbers www.computing.net/answers/programming/unique-random-numbers/1278.html