Question 1)

  1. What’s the chance of getting a sequential pair on two rolls of a die (eg, a 3 then a 4 counts, but a 4 then a 3 does not). (Hint: you can calculate this manually if you like, by counting up the sample space and finding the fraction of that sample space that consists of ordered pairs.)

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% \]

  1. Given a dartboard with a inner circle that is 2/3 of the total area, and a bulls-eye that is 5% of the total area (and entirely within the inner circle): if you are throwing a random dart (that is guaranteed to hit somewhere on the board, but everywhere inside is equally likely), what is the chance of hitting the bulls-eye conditional on knowing your dart is somewhere inside the innner circle?

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\]

  1. You take a test for a scary disease, and get a positive result. The disease is quite rare - 1 in 1000 in the general population. The test has a accuracy (sensitivity) of 95%, and a false positive rate of only 5%. What is the chance you have the disease?

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% \]

  1. What is the chance you have the disease if everything remains the same, but the disease is even rarer, 1 in 10,000?

answer:

\[ P(D)=0.0001 \]
\[ P(D|+)=\frac{P(+|D)P(D)}{P(+)}= \frac{(0.95)(0.0001)}{0.0509}=0.019=0.19% \]

  1. What does this tell you about the dangers of tests for rare diseases? answer:

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)

  1. You have a 20-side die. Using sample, roll it 1000 times and count the number of rolls that are 10 or less.
    die1 = c(1:20)
    SAMPLE<-sample(die1,1000,replace=TRUE)
    sum((SAMPLE==10)|(SAMPLE<10))
## [1] 489
  1. Generate a histogram using ggplot of 10,000 draws from a uniform distribution between 2 and 7.
    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)
    }
  1. What is the probability that a draw from this distribution will be between 1.5 and 3.2?
    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

  1. 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
  1. Using rbinom, roll a 100-sided die 100 times and report the total number of 7s you get.

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
  1. Because he is lazy, your teacher has assigned grades for an exam at random, and to help hide his deception he has given the fake grades a normal distribution with a mean of 70 and a standard deviation of 10. What is the chance your exam got a score of 85 or above? What is the chance you got a score between 50 and 60?

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