Results 1 to 5 of 5
 11232011, 11:31 AM #1Member
 Join Date
 Nov 2011
 Posts
 2
 Rep Power
 0
normal distribution random number algorithm
Hi,
I need to develop a method that basically returns a random number based on specific parameters as defined below.
The context is that this method wil go in a wider implementation of a discreteeven simulation model that reflect a specific traffic system.
Basically, the input requires to be of type double. The output must be of type double as well. I have the graph below which is to be used to development of the algorithm to return a random number.
As shown in the image, service time changes as time passes. between 06.00am and 07.10 (70 mins), mean service time is 1. Between 07.10 and 7.35 (70 mins till 95 mins), mean service time is 3 etc. I would require that the random number returned displays this characteristics, i.e. as from time NOW = 0 (mins) to time now = 70 (mins), there is a mean service time of 1 etc.
I am not exactly sure how to go along and develop this. Does it make sense to develop an array with probabilities?
Any help would be appreciated.
 11232011, 11:53 AM #2
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,414
 Blog Entries
 7
 Rep Power
 25
Re: normal distribution random number algorithm
Have a look at the Random class, it has a nextGaussian() method that returns a N(0, 1) pseudo random number (mean == 0, standard deviation == 1); you can always adjust such a number r by transforming it to m+s*r where the mean == m and the standard deviation is s.
kind regards,
JosBuild a wall around Donald Trump; I'll pay for it.
 11232011, 12:08 PM #3Member
 Join Date
 Nov 2011
 Posts
 2
 Rep Power
 0
Re: normal distribution random number algorithm
Josah,
thanks for your reply. Do you by any chance know of any resources that can help in the implementation / pseudocode?
thanks
 11232011, 12:16 PM #4
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 14,414
 Blog Entries
 7
 Rep Power
 25
Re: normal distribution random number algorithm
Build a wall around Donald Trump; I'll pay for it.
 11232011, 10:55 PM #5Moderator
 Join Date
 Feb 2009
 Location
 New Zealand
 Posts
 4,712
 Rep Power
 15
Re: normal distribution random number algorithm
Jos has addressed the question of generating numbers randomly such that they have a specified normal distribution as you mentioned in the title of your post.
However the graph you posted does not show a normal distribution. What it shows is the mean service time taking certain discrete values at different times. It looks like you need 6 actual service time distributions, one for each of the bars. Each one would have a mean being the height of the corresponding bar.
The problem is underspecified to the extent that the graph says nothing about the desired value of the standard deviation of actual service times at any time of day.
The distributions that have the mean values shown in the graph cannot be gaussian (normal) unless you are happy with allowing for arbitrarily large actual service times and, more worryingly, negative ones.
Similar Threads

Algorithm for filling random polygons
By theraccoon in forum Java 2DReplies: 3Last Post: 05182011, 06:35 PM 
Random Number Algorithm
By javauserjava in forum New To JavaReplies: 5Last Post: 04062011, 12:32 AM 
Random number help
By jgonzalez14 in forum New To JavaReplies: 5Last Post: 09162008, 09:13 AM 
Random number
By jithan in forum Advanced JavaReplies: 1Last Post: 06132008, 01:42 PM 
Generate a random number
By romina in forum New To JavaReplies: 1Last Post: 08072007, 05:23 AM
Bookmarks