Download Tossing a single die

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Statistics wikipedia , lookup

Probability interpretations wikipedia , lookup

Probability wikipedia , lookup

Transcript
Mathematics 241
Randomness
September 13
Goals for the day:
1. Words:
2. R:
(random) experiment, sample space, outcome, event, probablility, P (A), simulate
table, sample, replicate , logical vectors, course packages
3. Big idea:
our model for data collection involves randomness
Tossing a single die
1. Roll a single, six-sided die twelve times and record the twelve different outcomes.
2. The 12 rolls can be considered a sample. What is the population? Is it tangible or conceptual?
3. Each roll is, in the terminology of the book, an experiment. What is the sample space for this experiment? What
are the outcomes?
4. Give a plausible argument that the outcomes you have listed above are equally likely.
5. What percentage of the twelve throws did you “expect” to be sixes? Complete the following table:
12 die tosses
Expected percentage
Actual percentage
1
2
3
4
5
6
Page 2
Simulating a boatload of dice throws
1. We will use R to simulate the throws of 10,000 dice. Fill in the expected percentage line of this table:
10,000 die tosses
1
2
3
4
5
6
Expected percentage
Actual percentage
2. To simulate 10,000 tosses, we will use the sample function in R. The following simulates 1,000 tosses of a coin,
tabulates the results, and finds the percentages of each throw. Do the same for 10,000 throws and fill in the above
table. (Notice that die and s are vectors.)
> die = 1:6
> s=sample(die, 1000, replace=T)
> table(s)
s
1
2
3
4
5
6
156 146 164 177 185 172
> table(s)/1000
s
1
2
3
4
5
6
0.156 0.146 0.164 0.177 0.185 0.172
3. Comment on the deviation of actual percentages from expected percentages compared to the 1000 die roll example
above.
Non-equally likely outcomes
1. You are going to perform an experiment with the paper cup that you were supplied with. You are going to toss it
in the air 10 times and record whether it lands on its side, top rim, or bottom. First, make a prediction:
10 cup tosses
top
bottom
side
Expected percentage
Actual percentage
2. Toss the cup 10 times and fill in the actual percentage line above. You might have to decide what constitutes a
toss and you might have to get up and move to a place where you have enough room to carry out this experiment.
3. Based on your (small) sample, what would be a good estimate of the probability that the cup lands on its side?
4. Suppose that someone claimed that the probability of the cup landing on its side is 60%. Is your data proof that
they are wrong? Is your data strong evidence that they are wrong?
Page 3
5. Using simulation, we will investigate what would be likely to happen if the proability of the cup landing on its side
is actually 60%. Since we don’t have equally likely outcomes here, we need to modify the sample function with an
optional argument.
> cup=c('Side','Other')
> s=sample(cup,10,prob=c(.6,.4),replace=T)
> table(s)
s
Other Side
8
2
We want to know how surprising the result that you actually got would be in the true probability of landing on
its side was 60%. One way to do that would be to simulate this experiment 1000 times with the hypothesized
probabilities.
A useful R function is replicate. As its name suggests, this function repeats a function as many times as one
wishes. We usually use it this way: if f() is an R function that returns a number, replicate(n,f()) will return
a vector of the n numbers that result from calling the function f() n times. A simple example is an alternate way
of simulating dice throws:
> r=replicate(1000, sample(die,1))
> table(r)
r
1
2
3
4
5
6
168 168 187 165 167 145
Next we need a function that counts the number of times a cup lands on its side in 10 tosses.
> s=sample(cup,10,prob=c(.6,.4),replace=T)
> s=='Side'
[1] TRUE FALSE TRUE FALSE FALSE TRUE TRUE TRUE FALSE TRUE
> sum(s=='Side')
[1] 6
Now we’ll put these ideas together.
> r=replicate(1000, sum(sample(cup,10,prob=c(.6,.4),replace=T)=='Side'))
> table(r)
r
1
2
3
4
5
6
7
8
9 10
1
8 57 101 197 247 222 130 31
6
Do this simulation yourselves but use 10,000 repetitions. Answer this question:
What is the approximate probability of getting at least as many “sides” as you got in your 10 tosses if the true
probability of a single side is 60%?
6. Based on your answer in the last part, how strong do you think the evidence is that the probability of the cup
landing on its side is greater than 60%?
Page 4
Quiz:
1.
2.