Models with Randomness
Questions, Leftovers, Etc.
- Building the interest model
- Reading for next time
Pulse
What are the factors affecting someone's pulse?
What is Randomness?
- Measured with probabilities. What do you already know about
probability?
- Probabilities can measure unpredictability. We don't know what
the future holds.
- Probabilities can measure a lack of knowledge. We don't know
everything about the present.
- Probabilities can measure belief.
- How can we calculate probabilities? Do we just assume them? How do
we know that a coin toss is 50-50? Is every event with two outcomes
50-50?
Why and how is investing random?
- buy now, sell later
- present price may include predictions of the future
(Aside: If the market is down X percent one day and then goes back up
X percent then next day, where are you?)
This is the latest thing in financial advice.
Why is pollution random?
Why would the amount of pollution from a factory be random?
How do we model randomness?
- What are the probabilities for each face of a normal, six-sided die?
- If we roll a normal six-sided die 60 times, how many 3s would you
expect to get? Would you be shocked to get 10% fewer or more than that?
- If we roll a normal six-sided die 600 times, how many 3s would you
expect to get? Would you be shocked to get 10% fewer or more than that?
Dice--Integer Uniform
Extend can generate numbers from different distributions.
We can get a generator of die values by using the "Input Random Number"
block (Generic Lib > Input). open the dialog and look at the following:
- distribution: Note that everything depends on this being "Integer,
Uniform" This means that the random numbers are as if they were
consecutive numbers on the faces of a fair die, where we get to choose the
number of faces
- min: The smallest number on any face. For a normal, six-sided die,
this would be the number 1.
- max: The largest number on any face. For a normal, six-sided die,
this would be the number 6.
The number of faces on the die, call it N, is
N = (max - min) + 1
Why?
The probability of each face (each number) is
1/N
We'll also use a "histogram" (Plotter Lib > Histogram). We'll look at
the dialog for this, too.
- The number of bins.
- The range for the bins.
Finally, we'll look at how the number of rolls of the dice are
determined (Run > Simulation Setup > Continuous Simulations > Number of
Steps ).
Our model looks like:
We'll run some experiments to explore the questions above and whatever
other questions may arise during class.
N-sided Dice
Depending on our model, we may need dice with more or fewer than six
sides. (Gamers run into this all the time. Do you know about "percentile
dice" used in fantasy role-playing games?) In Extend, it's easy to handle
this by adjusting the "min" and "max" values.
Can you think of a physical way to have a 3-sided die?
What if you only had a normal 6-sided die and needed to make a
three-way decision?
Functions of Random Numbers
The uniform integer distribution is a pretty flexible kind of
generator. Still, there are things it can't do immediately, so we may
need to modify the numbers some.
Note that many of the kinds of random numbers have some fixed point
(such as starting at zero). Therefore, in the following discussion, we
will assume that the uniform integer distribution always has:
min=0
max=N-1
Why N-1?
location: 10-20
Suppose we needed numbers in the range from 10-20, inclusive, instead
of starting at 0? What could we do?
- First of all, now many numbers are there from 10 to 20? So, what is
the value of N?
- We need to adjust the numbers coming out of our random number
generator so that the smallest is 10 instead of 0. How can we do that?
We call this shifting or translating the random variable:
changing its location without changing the range or number of values or
anything else about the random variable.
scale: 0,10,20...50
What if we needed numbers that weren't consecutive, but were in
distances of 10 or 0.1? Use scaling. Like a change of units.
More Generality
Use the equation block.
The Equation block in Extend
Suppose, just for the sake of argument, that we want to compute
Y=3X2+4X+5
- The formula goes in the big box.
- The value must be named "Result," unless you change the name above.
- The "inputs" must be named "Val1" and so forth, again, unless you
change the names.
- Just like in Excel, there are built-in functions you can use. Click
on "Show ModL Functions".
- The equation must end in a semi-colon.
Let's try having the 3 come from a constant block instead of being
built into the equation.
Sums of two dice
What's the difference between
Y=2X
and
Y=X+X
Let's build a model that has two random number generators (with
identical parameters) and another that has a single random number
generator but multiplies the result by 2.
- Don't forget to modify the
number of bins in the histogram! Modifying the range might be nice, too.
- Run for many more times.
- Plot the results as a histogram
- Why is the histogram of the sum not uniform?
The Multisim Plotter
To compare runs, use Plotter, Multisim. Let's build a simple
simulation that just sums the random numbers we get. We only need a
random number generator, an accumulator, and a plotter (multisim).
In Run > Simulation Setup, modify the number of runs to 5 and the
number of steps to be 10. Then run the model. We'll look at the multisim
plot together:
- There is one line for each simulation run
- Each line starts at zero since that's the initial value of the
accumulator. Extend automatically reinitializes all the state variables
at the beginning of each run.
- Notice that sometimes the lines cross and re-cross. Does this have
any significance? If so, what?
- How many lines do you suppose we could look at before it becomes a
hopeless mess?
- Notice that the multisim plotter has only one input. If it had more
than one input, it would be even harder to tell one line from another.
Pitfall: different axes
Consider an alternative way to do this:
- Put a regular plotter (I/O) into the model, using just one input
- Run the model again
- This will create several plots which you can get to by clicking on the
number in the diagonal box just above the dividing line in the plotter
window. Unfortunately,
- You can't keep more than four plots
- You can't compare them side by side
- The scales can be different, so even a side-by-side comparison might
be deceiving.
All in all, not a good option. But maybe for some purposes.
Samples versus Distributions (Populations)
If we roll a die, we get a particular number. That number is called a
sample. What is it a sample of? It's a sample of a
population of possible outcomes, namely the numbers 1-6.
When we add randomness to a simulation, each run becomes a sample from
a (possibly infinite) population of possible runs.
Modifying the Interest Model to use Randomness
We said that the long-run average return on stocks is about 10%.
Suppose that the year to year returns range from -20% to +30%.
Let's use the Integer, Uniform to create this. For simplicity, we'll
use steps of 0.1.
- Start with -20% to 30%, in steps of 0.1
- Scale this to be -0.2 to 0.3, in steps of 0.001
- Scale this to -200 to 300, in steps of 1
- We can generate this with by shifting an Integer Uniform from 0 to 500
- Therefore, we choose an Integer Uniform, make the min 0 and the max
500, and feed it into the following equation:
Y=(X-200)/1000;
Here's a model to play with:
random-return.mox
Looking at Randomness in the Lake Pollution Model
The Lake Model already has a random number generator in it. We'll
replace it with a Integer Uniform between 0 and 2000.
This work is licensed under a Creative Commons
License |
|
|
|