title: “Distribution of Random Variables” author: “Brian K. Liles” date: “September 17, 2017” output: html_document

3.2

Area under the curve

3.4

Triathlon Times

italicsWrite down the short-had for these two normal distributions N(mean=4313,sd=583) N(mean=5261,sd=807)

What are the Z-scores for Leo’s and Mary’s finishing times? What do these Z-scores tell you?

#Leo completed the race in 4948 seconds
leo_z <- (4948-4313)/583
#View Leo's Z-score
leo_z
## [1] 1.089194
#Mary completed the race in 5513 seconds
mary_z <- (5513-5261)/807
#View Mary's Z-score
mary_z
## [1] 0.3122677

Did Leo or Mary rank better in their respective groups? Explain your reasoning.

Mary did better in her particular group than Leo did in his. Overall, she is closer to the womens standard deviation.

What percent of the triathletes did Leo finish faster than in his group?

pnorm(1.09,lower.tail = FALSE)
## [1] 0.1378566

What percent of the triathletes did Mary finish faster than in her group?

pnorm(0.31,lower.tail=FALSE)
## [1] 0.3782805

If the distributiions of finishing times are nearly normal, would answers to parts (b)-(e)change? Explain your reasoning. Absolutely not since the outcomes are near normal.

3.18

Heights of Female College Students

#Heights of 25 female college students
fhgt <- c(54,55,56,56,57,58,58,59,60,60,60,61,61,62,62,63,63,63,64,65,65,67,67,69,73)
fhgtmean <- mean(fhgt)
fhgtsd <- sd(fhgt)
#View newly created variables
fhgtmean
## [1] 61.52
fhgtsd
## [1] 4.583667

The mean height is 61.52 inches with a standard deviation of 4.58 inches. Use this information to determine if the heights approximately follow the 68-95-99.7% rule.

The distribution follows the 68-95-99.7% Rule.

#Determine the empirical range
#Find the range for 68%
Low68 <-fhgtmean - fhgtsd
High68 <-fhgtmean + fhgtsd
Low95 <-fhgtmean - (2 * fhgtsd)
High95 <-fhgtmean + (2 * fhgtsd)
Low99_7 <-fhgtmean - (3 * fhgtsd)
High99_7 <-fhgtmean + (3 * fhgtsd)
#Create a data frame listing the values
empirical <- data.frame(Low68,High68,Low95,High95,Low99_7,High99_7)
empirical
##      Low68   High68    Low95   High95 Low99_7 High99_7
## 1 56.93633 66.10367 52.35267 70.68733  47.769   75.271

Do these data appear to follow a normal distribution? Explain your reasoning using the graphs provided.

Based on the density histogram and the normal probability distribution, it seems the outcome is unimodal and it somewhat follows a normal distribution but skews to the right towards the upper tails.

#Construct a density histogram
hist(fhgt, probability=TRUE, ylim=c(0,0.09))
x <-50:75
y <-dnorm(x=x, mean = fhgtmean, sd=fhgtsd)
lines (x=x, y=y, col="blue")

#Construct a normal probability plot
qqnorm(fhgt)
qqline(fhgt)

3.22

Defective Rate

A machine that produces a special type of transistor (a component of computers) has a 2% defective rate. The production is considered a random process where each transistor is independent of the others.

What is the probability that the 10th transistor produced is the first with the defect?

#The success rate is 98%
#The faiilure rate is 2%
(0.98^9)*(0.02)
## [1] 0.01667496

What is the probability that the machine produces no defective transistors in a batch of 100?

0.98^100
## [1] 0.1326196

On average, how many transistors would you expect to be produced before the first with a defect? What is the standard deviation?

#Failure rate 2%
ptrans <- 0.02
#Expected value
meanstrans <- 1/ptrans
#Expected value and its variability
sdtrans <- sqrt((1-ptrans)/(ptrans^2))
#View output
meanstrans
## [1] 50
sdtrans
## [1] 49.49747

Another machine that also produces transistors has a 5% defective rate where each transistor is produced independent of the others. On average, how many transistors would you expect to be produced with this machine before the first with a defect? What is the standard deviation?

#Faiure rate 5%
ptrans <- 0.05
#Expected value
meanstrans <- 1/ptrans
#Expected value and its variability
sdtrans <-sqrt((1-ptrans)/(ptrans^2))
#View output
meanstrans
## [1] 20
sdtrans
## [1] 19.49359

Based on your answers to parts (c) and (d), how does increasing the probability of an event affect the mean and standard deviation of the wait time until success?

Increasing the probability seems to have a little effect on the relationship of the mean and standard deviation.

3.38

Male Children

While it is often assumed that the probabilities of having a boy or a girl are the same, the actual probability of having a boy is slightly higher at 0.51. Suppose a coule plans to have 3 kids.

Use the binomial model to calculate the probability that two of them will be boys.

n <- 3
k <- 2
p <- 0.51

#The factorial of a number is the product of all the integers from 1 to tht number

bd <- factorial(n)/(factorial(k)*factorial(n-k))

boy_prob <- bd*(p^k)*((1-p)^(n-k))

#View outcome
boy_prob
## [1] 0.382347

Write out all possible orderings of 3 children, 2 of whom are boys. Use these scenarious to calculate the same probability from part (a) but using the addition rule for disjoint outcomes. Confirm that your answers from parts (a) and (b) match.

BBB GGG BGG GBB BGB GBG BBG GGB

If we wanted to calculate the probability that a couple who plans to have 8 kids will have 3 boys, briefly describe why the approach from part (b) would be more tedious than the approach from part (a)

By hand, it leaves too much for error

#The choose function is useful for calculating the number of ways to choose k successes in n trials
choose(8,3)
## [1] 56

3.42

Serving in Volleyball

A not so-skilled volleyball player has a 15% chance of making the serve, which involves hitting the ball so it passes over the net on a trajectory such that it will land in the opposing team’s court. Suppose that her serves are independent of each other.

What is the probability that on the 10th try she will make her 3rd successful serve?

n <-10
k <-3
p <-0.15

bd <- factorial(n)/(factorial(k)*factorial(n-k))

goodserve <-bd*(p^k)*((1-p)^(n-k))
#View outcome
goodserve
## [1] 0.1298337

Suppose she has made two successful serves in nine attempts. What is the probability that her 10th serve will be successful.

n <-9
k <-2
p <-0.15

bd <- factorial(n)/(factorial(k)*factorial(n-k))

goodserve9 <-bd*(p^k)*((1-p)^(n-k))
#View outcome
goodserve9
## [1] 0.2596674

Even though parts (a) and (b) discuss the same scenario, the possibilites you calculated should be different. Can you explain the reason for this discrepancy?

The number of successes over attempts changed, 3 successes over 10 attempts is 30 percent while 2 hits out of 9 attempts is less.