k <- 23
m <- 10^4
x <- numeric(m)
for (i in 1:m)
{
b <- sample(1:365, k, replace = TRUE)
x[i] <- k - length(unique(b))
}
table(x)
x
0 1 2 3 4 5 6
4870 3704 1153 240 27 5 1
More on probabilities
2024-09-30
5. Moving on to notion of dependence and independence
6. Updating probabilities
Jane is 28 years old, single, outspoken, and very bright. She majored in philosophy. As a student, she was deeply concerned with issues of discrimination and social justice. Which is more likely?
A birthday problem in disguise: How many people? How many birthdays?
Setup the experiment. Put a group of \(k\) people into \(m\) rooms.
Set the group size: k <- 23
Set the number of rooms: m <- 10^4
Set storage to “summarize” a relevant aspect of the room: x <- numeric(m)
Repeat the following commands for each room i
:
Assign to \(k\) people any of the 365 possible birthdays with replacement: b <- sample(1:365, k, replace = TRUE)
Pay attention to x[i] <- k - length(unique(b))
for every room.
Present the results: table(x)
You can also implement the code through the replicate command. But you need define a function.
nsim <- 10^4
match <- function(k)
{
b <- sample(1:365, k, replace = TRUE)
return(sum(diff(sort(b))==0))
}
x <- replicate(nsim, match(23))
table(x)
x
0 1 2 3 4 5
4986 3604 1192 198 19 1
Modify the code to allow for “fuzzy” matches: Say, birthdays that are within a day apart are counted as a match.
Let us watch the following video:
https://www.cornell.edu/video/the-tonight-show-with-johnny-carson-feb-6-1980-excerpt
Were they talking about the birthday problem? Why or why not?
Let \(\Omega=\{0,1,\ldots\}\). Prove that there does not exist a uniform distribution on \(\Omega\).
Things to note:
A prize is placed at random behind one of three doors.
You pick a door. To be concrete, let’s suppose you always pick door 1.
Now Monty Hall chooses one of the other two doors, opens it and shows you that it is empty. He then gives you the opportunity to keep your door or switch to the other unopened door.
Should you stay or switch? Intuition suggests it doesn’t matter. The correct answer is that you should switch. Prove it.
Three options, using what we have so far: