Analytical Statistics Problem Set 3
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Problem Set 3
Analytical Statistics
1. A professor gives students a pop quiz with 5 true or false questions. Eighty percent of the students are well-prepared for the pop quiz, but twenty percent are not. Students who are prepared have a 85% chance of answering each question correctly, but the students who are unprepared simply randomly guess and have a 50% chance. Find the probability that a student was well-prepared under the following scenarios:
(a) Answered 2 correctly
(b) Answered 3 correctly
2. A fair coin is flipped 20 times. Your friend proposes a bet where if it lands on heads exactly 10 times, you win $4, but if it lands on heads 11 or more times or 9 or less times, you lose $1. Should you take the bet? In other words, find the expected value of the bet and if it is positive you should take it.
3. Two candidates face each other in an election. The Democratic candidate is sup- ported by 46% of the population, and the Republican candidate is supported by 54%. In other words, if you randomly chose a voter and asked them who they plan to vote for, there would be a 46% chance they would say they support the Democratic candidate. Suppose you run a poll of 8 people (randomly choose 8 people). What is the probability that less than half of them (3 or fewer) would support the Republican candidate?
4. You flip a coin 3 times. Each time the coin lands on heads, you roll a die and record the result. If it lands on tails you don’t roll the die and you don’t record a result. In other words, if your coin lands on heads three times, then you would roll the die 3 times. If the coin lands on heads once, then you would only roll the die once. If the roll(s) of the dice (or die if it was only one) add up to the number four. Find the following:
(a) Probability that the coin landed on heads once
(b) Probability that the coin landed on heads twice
(c) Probability that the coin landed on heads three times
(d) Expected value of the number of times the coin landed on heads.
5. Let X be a random variable such that
E[X2] − E[X]2 = 12
Find
(a) Var(X)
(b) E[(cX)2] − E[cX]2
(c) Var(cX)
R Exercises
1. The code provided below uses a for loop to simulate conducting 10,000 polls of 8 peo- ple in which each person has 58% probability of being a supporter of the Democratic candidate and a 42% probability of being a supporter of the Republican. The way the loop works is it runs through the code inside the loop 10,000 times, but changing the value of i with each iteration (i is 1 in the first iteration, 10,000 in the last).
# Define a vector of integers that has 10,000 elements.
poll_sims = vector(length = 10000, mode = "integer")
# for loop to simulate 10,000 polls
for (i in 1:10000) {
# Do a poll of 8 people in which each person has a 58% chance of supporting the # Democratic candidate and 42% chance of supporting the Republican.
poll = sample(c("Democrat", "Republican"), size = 8, replace = T, prob = c(.58, .42) # Count the number of people who support the Democrat and store the result in the # poll_sims vector as the ith result.
poll_sims[i] = sum(poll == "Democrat")
}
# Visualise the poll_sims vector using basic R
plot(factor(poll_sims))
# Visualise the poll_sims vector using tidyverse
library(tidyverse)
qplot(factor(poll_sims)) + geom_bar()
(a) Modify the code above to run simulations of the situation from problem (5) above (where 46% support the Democrat and 54% the Republican). Find the fraction of the simulations in which less than half the people (3 or fewer) support
the Republican candidate. Compare this result to your answer in Question 5 of the previous section.
(b) Change the code to simulate 10,000 polls of 100 people (rather than 10,000 polls of 8). Find the fraction of simulations in which less than half the people support the Democratic candidate. In other words, use the simulations to approximate
the likelihood that a poll of 100 people will incorrectly guess the winner of the election.
(c) Graph the simulations so you can visualize the distribution.
2. In question (4) the question described a process of flipping a coin three times, rolling dice for time it lands on heads and adding up the results of the die rolls. Below is the
R code to simulate that process once and then put the results in a data.frame with one column for total flips landing heads and one column for the sum of the die rolls.
# Flip a coin three times, heads is 1, tails is zero
flips = sample(x = c(0, 1), size = 3, replace = T)
# Calculate the number of times it landed heads
sum_flips = sum(flips)
# If it landed on heads more than zero times execute the code in brackets
if (sum_flips > 0) {
# Roll die sum_flips times
rolls = sample(1:6, size = sum_flips, replace = T)
# Add up the different rolls
sum_rolls = sum(rolls)
} else {
# If it didn’t land on heads, let sum_flips be zero
sum_rolls = 0
}
# Store sum_flips and sum_rolls in a data set
sim_results = data.frame(sum_flips, sum_rolls)
Modify the code using a for-loop to simulate that process 100,000 times.
(a) Use the results to approximate the answers to question 4. In other words, using the results of your simulation, find an approximation of the following probabilities if the sum of the rolls of the dice add up to four.
i. Probability that the coin landed on heads once
ii. Probability that the coin landed on heads twice
iii. Probability that the coin landed on heads three times
iv. Expected value of the number of times the coin landed on heads.
(b) Now approximate the same values if the rolls of the dice added up to twelve instead of four.
2022-02-14