Question 1)
answer:
The desiered events are :
{(1 2),(2 3),(3 4),(4 5),(5 6)} The total number of all possible oucomes are 6*6=36 As a result, \[P(sequential pair) = \frac{5}{36}=13.8% \]
A: Inner circle event
B: Bulls-eye event
\[P(B|A)= \frac{P(A|B)P(B)}{P(A)}\] \[P(A)=\frac{2}{3}\] \[P(B)=\frac{5}{100}\] \[P(A|B)=1\] since all darts in B are always in A. =========> \[P(B|A)=\frac{1*(0.05)}{\frac{2}{3}}=0.033\]
answer:
P(D) Probability of having the disease=0.001.
P(+) Probability of positive experiment result. \[ = P(+|D)P(D) + P(+|ND)P(ND)=(0.95)(0.001)+(0.05)(1-0.001)=0.00095+0.04995=0.0509\]
\[P(+|D)=0.95\]
\[ P(D|+)=\frac{P(+|D)P(D)}{P(+)}= \frac{(0.95)(0.001)}{0.0509}=0.019=1.9% \]
answer:
\[ P(D)=0.0001 \]
\[ P(D|+)=\frac{P(+|D)P(D)}{P(+)}= \frac{(0.95)(0.0001)}{0.0509}=0.019=0.19% \]
This analysis shows that for the rare diseese this test does not provide possible a right answer and its probablilty to be accurate is very low<2%. We better avoid making these tests for rare disease.
Question 2)
die1 = c(1:20)
SAMPLE<-sample(die1,1000,replace=TRUE)
sum((SAMPLE==10)|(SAMPLE<10))
## [1] 489
library(ggplot2)
randunifs <- runif(10000,2,7) # This function, finds 10000 number between 2 and 7 with the uniform distribution.
ggplot(data=data.frame(randunifs),aes(x=randunifs)) + geom_histogram(aes(y=..density..)) + xlim(0, 9) + ylab("density") + xlab("outcome")
c) Try to write down the equation for this probability density function.
uniformfun <- function(x)
{
ifelse(x>=2&x<=7,1,0)
}
uniformcdf <- function(x)
{
ifelse(x>=2&x<=7,(x-2)/(7-2),ifelse(x<2,0,1))
}
ggplot(data=data.frame(x=c(0:8)),aes(x)) + stat_function(fun=uniformcdf)
Prob=uniformcdf(3.2)-uniformcdf(1.5);
Prob
## [1] 0.24
Question 3
Using R’s cdf for the binomial, what is the probability of getting 500 or fewer “20”s when rolling your 20-sided die 10,000 times. Looking back at 2a, what proportion of your rolls were actually 20s?
answer:
x== # of “20” appearance when we roll our 20-sided die 10000 times. The questing is asking what is P(0=<x<=500).
cumulative probability of getting three or fewer heads out of four flips
pbinom(500,10000,0.05)
## [1] 0.511895
Now, looking back Q2.a we want to find what proportion of our rolls were actually 20s.
die2 = c(1:20)
SAMPLE<-sample(die1,10000,replace=TRUE)
n<-sum((SAMPLE==20))
proportion_20<-n/10000;
proportion_20
## [1] 0.0519
answer:
m_7<-rbinom(1,100,0.07) #here 1 is the number of full experiment. if 1 was 2, we had 200 experiments.
m_7
## [1] 10
c)You are a klutz, and the average number of times you drop your pencil in a day is 1. Using the poisson functions in R, what’s the chance of dropping your pencil two or more times in a day? (Hint: calculate the chance of dropping it one or fewer times, and then take 1 minus that.)
answer:
droping_prob_more_2<- 1-ppois(1,1)
droping_prob_more_2
## [1] 0.2642411
answer:
upper_85_prob<- 1-pnorm(85,70,10)
upper_85_prob
## [1] 0.0668072
between_60_50_prob<- pnorm(60,70,10)-pnorm(50,70,10)
between_60_50_prob
## [1] 0.1359051