V.3.1 Seeds
In many simulations, it is often desirable to try to reproduce some behaviour. For example, with many models, an initial configuration is generated by calling the Random function. If you wanted to repeat a particular simulation, but possibly increase the resolution (grid size), or bump up the number of values that each site can take on, then you will find yourself wanting to recreate random number sequences. This can be accomplished by reseeding the random number generator.
This seeds the random number generator and then gives 5 random reals between 0 and 1.
Reseeding the generator with the same seed causes the same sequence to be generated.
V.3.1a How would you set a random seed for the congruential methods of chapter V.1
V.3.2 Built-in Distributions
Random numbers can be generated using any probability distribution. For example, if you wanted to generate samples from a normal (or Gaussian) distribution, this can be done by giving an argument to the Random function.
First we will load a package that contains a variety of continuous probability distributions.
Here are all the distributions whose definitions are now loaded into memory.
We will now further look into the Normal distribution
The Normal Distribution
A random variable is said to be normally distributed with mean μ and variance if its probability density function is given by f(x) = Intuitively the probability density function,, is a measure of how likely it is that the random variable will be near . The normal density is a bell-shaped curve that is symmetric about μ. The variance is a measure for the width of the curve.
V.3.2a Plot the normal distribution for different values for the mean and the variance.
Here is a function that generates a random variable from the normal distribution with mean 0 and standard deviation equal to 1.
Here are eight samples using this distribution.
You can get a graphical display of the distribution by putting sample points into "bins" and then counting the number of points in each bin.
First, we will create a large set of samples.
This counts the number of sample points in the range from -4 to -3.9, then those from -3.9 to -3.8, etc.
Now we can display the distribution.
V.3.2b Scale your data to a area of 1 and plot together with the normal function. What conclusions can be drawn?
V.3.2c Apply the same bin test to the congruential methods.
|