Wyższa Szkoła Zarządzania i Bankowości
LECTURESNOTEBOOKSPACKAGES
5 Modeling with Random Numbers
5.3 Seeds and Probability Distributions

1 Introduction to Simulation and Modeling
2 Discrete Medeling (L-Systems)
3 Population Dynamics
4 Number Representation and Error Propagation
5 Modeling with Random Numbers
5.1 What is a Random Number?
5.2 Generating Random Numbers with Mathematica
5.3 Seeds and Probability Distributions
5.4 Integration by Random Numbers and Numerical Methods
5.5 A Drunken Man's Walk
6 Heat Transfer in a Rod (Connection Mathematica and C: MathLink)
7 Special Topics in Stochastic Finance
8 Appendix: Introduction to Mathematica
9 Population Dynamics in Vensim®PLE
     
 

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.

[Graphics:Images/V.3_gr_1.gif]

This seeds the random number generator and then gives 5 random reals between 0 and 1.

[Graphics:Images/V.3_gr_2.gif]

Reseeding the generator with the same seed causes the same sequence to be generated.

[Graphics:Images/V.3_gr_3.gif]

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.

[Graphics:Images/V.3_gr_4.gif]

Here are all the distributions whose definitions are now loaded into memory.

[Graphics:Images/V.3_gr_5.gif]

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 [Graphics:Images/V.3_gr_6.gif]if its probability density function is given by
        f(x) = [Graphics:Images/V.3_gr_7.gif][Graphics:Images/V.3_gr_8.gif]
Intuitively the probability density function,[Graphics:Images/V.3_gr_9.gif],  is a measure of how likely it is that the random variable will be near [Graphics:Images/V.3_gr_10.gif]. The normal density is a bell-shaped curve that is symmetric about μ. The variance [Graphics:Images/V.3_gr_11.gif] 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.

[Graphics:Images/V.3_gr_12.gif]

Here is a function that generates a random variable from the normal distribution with mean 0 and standard deviation equal to 1.

[Graphics:Images/V.3_gr_13.gif]

Here are eight samples using this distribution.

[Graphics:Images/V.3_gr_14.gif]

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.

[Graphics:Images/V.3_gr_15.gif]

This counts the number of sample points in the range from -4 to -3.9, then those from -3.9 to -3.8, etc.

[Graphics:Images/V.3_gr_16.gif]

Now we can display the distribution.

[Graphics:Images/V.3_gr_17.gif]
[Graphics:Images/V.3_gr_18.gif]
[Graphics:Images/V.3_gr_19.gif]
[Graphics:Images/V.3_gr_20.gif]
[Graphics:Images/V.3_gr_21.gif]
[Graphics:Images/V.3_gr_22.gif]

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.


 
     
  Lectures | Notebooks | Packages

 
  Copyright © 2003 Wyższa Szkoła Zarządzania i Bankowości. Wszystkie prawa zastrzeżone
webmaster@wszib.edu.pl