MATH 1180: Calculus for Biologists II (Spring 2011)

advertisement
MATH 1180: Calculus for Biologists II (Spring 2011)
Lab Meets: March 30, 2011
Report due date: April 6, 2011
Section 002: Wednesday 9:40−10:30am
Section 003: Wednesday 10:45−11:35am
Lab location − LCB 115
Lab instructor − Erica Graham, graham@math.utah.edu
Lab webpage − www.math.utah.edu/~graham/Math1180.html
Lab office hours − Monday, 9:00 − 10:30 a.m., LCB 115
Lab 09
General Lab Instructions
In−class Exploration
Review: Last time, we reviewed some key concepts in probability and stochastic simulations.
Background: This week, we will look at some new concepts in probability introduced in Chapter 7,
including joint, marginal and conditional probability distributions.
restart;
with(Statistics):
read("/u/ma/graham/public_html/Math1180/1180files/dicefun"):
Suppose two fair dice are rolled, but the second die is re−rolled until the score is less than or equal to that on
the first. For example, if the first die comes up 3, then the second has to be rolled again and again until it
comes up 3 or less. We will use the DiceSim( ) command in the dicefun file we just imported to simulate
this situation for some number of event pairs. Since we have 2 dice being rolled, a first (F) and a second
(S), we have a total of 36 possible outcomes. Note that each random variable by itself has 6 simple events.
A small subset of the possible event pairs is
{F=1 and S=2; F=3 and S=2; F=4 and S=6; F=5 and S=3}.
The goals of our simulation are to determine the joint probability distribution of the two random variables F
and S and to see how F and S relate to each other. To start, we’ll generate some RollData for 75 trials.
Then we’ll plot the results of F and S in histograms using the dicefun command MargPlot( ).
Ntrials:=75:
RollData:=DiceSim(Ntrials):
MargPlot(RollData);
probability
Marginal probabilities for F
Marginal probabilities for S
1
1
0.8
0.8
0.6
0.6
0.4
0.2
0
2
15
4
25
3
25
1
2
3
F
14
75
13
75
4
5
17
75
6
0.4
8
25
7
25
0.2
0
1
2
4
25
3
7
75
7
75
4
75
4
5
6
S
Page 1 of 5
probability
probability
Conditional distribution
with F=3
1
0.8
0.6 4 4
9 9
0.4
1
0.2
9 0 0 0
0
1 2 3 4 5 6
S
Conditional distribution
with F=4
1
0.8
0.6
0.4 3 27 3 27
14
0.2 14
0 0
0
1 2 3 4 5 6
S
Conditional distribution
with F=5
1
0.8
0.6
4
4
0.4 2 2 13
13
1
0.2 13 13
13
0
0
1 2 3 4 5 6
S
Conditional distribution
with F=6
1
0.8
0.6
4
0.4
3 4
2 2 17 2
17 17
0.2 17 17
17
0
1 2 3 4 5 6
S
probability
Conditional distribution
with F=2
1
3
0.8
4
0.6
0.4 1
4
0.2
0 0 0 0
0
1 2 3 4 5 6
S
probability
Conditional distribution
with F=1
1
0.8
0.6
0.4
0.2
0 0 0 0 0
0
1 2 3 4 5 6
S
probability
probability
The marginal probabilities above describe the individual probability of a die giving a specific. So, on the
left, we can see that the first die is (for the most part) equally likely to come up with 1,2,3,4,5 or 6, whereas
S has a different distribution for its simple events. Recall that a marginal probability for a single event, say
S = 1, is denoted Pr(S = 1) and equals the sum of the joint probabilities of all event pairs containing S=1:
Pr(S=1) = Pr(S=1 and F=1) + Pr(S=1 and F=2) + Pr(S=1 and F=3) + Pr(S=1 and F=4) + Pr(S=1 and F=5) +
Pr(S=1 and F=6).
Our (read: your) goal is to identify these joint probabilities and verify that they do what we think they
should. To do this, we’ll need a little bit more information, specifically the conditional probability
distribution of each event pair. The useful dicefun command CondPlot( ) can help with this.
CondPlot(RollData);
Each panel contains a different F value. The accompanying histograms allow us to determine if there’s a
shift in the distribution of S as F varies. For example, Pr(S = s | F = 1) is 0 for every value of s EXCEPT
when s=1. Notice how that changes as we increase F.
Lastly, the stuff we saved to RollData actually has another bit of interesting information in it. Using,
another dicefun command, CombinedPlot( ), we can see the results of each event pair as well has how many
times the computer had to roll the second die before it could move on to the next pair. The orange lines
indicate the possible simple events (1 through 6). The black line is the number of 2nd die rolls taken before
arriving at the plotted S value (blue).
CombinedPlot(RollData);
Page 2 of 5
6
8
7
5
results
4
5
3
4
3
2
roll count
6
2
1
1
0
0
0
10
20
F result
30
40
event pair
S result
50
60
70
number 2nd rolls
Please copy the entire section below into a new worksheet, and save it as something you’ll
remember.
Lab 09 Homework Problems
Your Full Name:
Your (registered) Lab Section:
Useful Tip #1: Read each problem carefully, and be sure to follow the directions specified for each
question! I will take a vow of silence if you ask me a question that is clearly stated in a problem.
Useful Tip #2: Minimize your code by not simply copying and pasting absolutely everything we do in
class. See if you can eliminate unnecessary commands by knowing what it is you have to do and what tools
you (minimally) need to do it.
Useful Tip #3: When in doubt, restart!
Useful Tip #4: When you reopen a saved .mw file, remember to re−execute everything in order to use
previously defined things. Maple can show you the output of what you’ve done before, but it won’t
remember how it got there.
Useful Tip #5: Read through your completed assignment again before handing it in, to make sure that
things make sense. It helps both the learning and grading processes.
Paper−saving tip: Make the size of your output graphs smaller to save paper when you print them. Please
ask me if you’re unsure of how to do this. (You can see how much paper you’d use beforehand by going to
File
Print Preview.) Also, please DO NOT attach printer header sheets (usually yellow, pink or blue) to
your assignment. Recycle them instead!
(0)(a) Read the useful tips, especially #4 and #5.
(b) Import the Maple Statistics package and dicefun file we used in class.
with(Statistics):
Page 3 of 5
read("/u/ma/graham/public_html/Math1180/1180files/dicefun"):
Note: You will be penalized one raw point for each unnecessary Maple command. Make sure you
understand what’s needed and what’s superfluous!
(1)(a) Looking at the last figure we created in class, under what circumstances is the number of rolls of the
2nd die higher? In other words, what types of event pairs more frequently lead to a lot of re−rolling?
(b) When is re−rolling almost unnecessary?
(2)(a) Simulate 200 trials of the same dice−rolling situation described in class, and save your outcomes as
’RollData.’
Please SUPPRESS the resulting data set.
## simulation command(s)
(b) Generate both the marginal and conditional probability plots for your RollData.
## plot marginal distributions
## plot conditional distributions
(3) Use the marginal and conditional distributions to calculate the joint probabilities for each event pair,
and write all 36 of them in the following table.
Required: Keep your answers in fraction form. I will not grade any tables with decimals.
S
1
2
3
4
5
6
row
sums
1
2
F
3
4
5
6
column sums
(4)(a) Calculate the row (F) and column (S) sums, and write them in the appropriate boxes in the table.
There should be 6 column sums and 6 row sums.
(b) Do these sums match the marginal probabilities in the first set of histograms generated by MargPlot( )?
If not, you need to correct the entries in your table.
(c) Add the 6 row sums together. What do you get?
(d) Add the 6 column sums together. What do you get?
(e) Why do these results make sense?
(5)(a) Now that you have the joint probabilities, use them to calculate the conditional probabilities Pr(F|S)
for all F and S values. Write all 36 numbers in the table below, grouped by S values. Use the fact that the
Page 4 of 5
conditional probability Pr(F=i|S=j) = Pr(F=i and S=j)/Pr(S=j).
S=1
S=2
S=3
S=4
S=5
S=6
Pr(F=
1|S=1)
Pr(F=
1|S=2)
Pr(F=
1|S=3)
Pr(F=
1|S=4)
Pr(F=
1|S=5)
Pr(F=
1|S=6)
Pr(F=
2|S=1)
Pr(F=
2|S=2)
Pr(F=
2|S=3)
Pr(F=
2|S=4)
Pr(F=
2|S=5)
Pr(F=
2|S=6)
Pr(F=
3|S=1)
Pr(F=
3|S=2)
Pr(F=
3|S=3)
Pr(F=
3|S=4)
Pr(F=
3|S=5)
Pr(F=
3|S=6)
Pr(F=
4|S=1)
Pr(F=
4|S=2)
Pr(F=
4|S=3)
Pr(F=
4|S=4)
Pr(F=
4|S=5)
Pr(F=
4|S=6)
Pr(F=
5|S=1)
Pr(F=
5|S=2)
Pr(F=
5|S=3)
Pr(F=
5|S=4)
Pr(F=
5|S=5)
Pr(F=
5|S=6)
Pr(F=
6|S=1)
Pr(F=
6|S=2)
Pr(F=
6|S=3)
Pr(F=
6|S=4)
Pr(F=
6|S=5)
Pr(F=
6|S=6)
(b) Sketch (by hand) the conditional distributions in a histogram for each S outcome (1 through 6). Your 6
sketches should be in the same format as the output from CondPlot( ) above. Please use a ruler or
comparable straight edge for these (more of a requirement than a request).
(6)(a) How does this set of conditional distributions for S compare to those for different F values?
Specifically, explain how these two random variables relate to each other.
(b) In which cases, if any, are the conditional probabilities given F equal to 1? If such a case exists, why
does this make sense?
(c) In which cases, if any, are the conditional probabilities given S equal to 1? If such a case exists, why
does this make sense?
Did you remember to save paper? (Make sure all plot titles and labels will be visible when you print!
)
Page 5 of 5
Download