library(ggplot2)
library(qqplotr)
##
## Attaching package: 'qqplotr'
## The following objects are masked from 'package:ggplot2':
##
## stat_qq_line, StatQqLine
Area under the curve, Part I. (4.1, p. 142) What percent of a standard normal distribution \(N(\mu=0, \sigma=1)\) is found in each region? Be sure to draw a graph.
x=seq(-3,3,length=100)
y=dnorm(x,mean=0,sd=1)
plot(x,y,type="l")
x=seq(-1.35,-3,length=100)
y=dnorm(x,mean=0,sd=1)
polygon(c(-1.35,x,-1.35),c(0,y,0),col="red")
pnorm(-1.35)
## [1] 0.08850799
x=seq(-3,3,length=100)
y=dnorm(x,mean=0,sd=1)
plot(x,y,type="l")
x=seq(1.48,3,length=100)
y=dnorm(x,mean=0,sd=1)
polygon(c(1.48,x,1.48),c(0,y,0),col="red")
1-pnorm(1.48)
## [1] 0.06943662
x=seq(-3,3,length=100)
y=dnorm(x,mean=0,sd=1)
plot(x,y,type="l")
x=seq(-.4,1.5,length=100)
y=dnorm(x,mean=0,sd=1)
polygon(c(-.4,x,1.5),c(0,y,0),col="red")
pnorm(1.5)-(pnorm(-.4))
## [1] 0.5886145
x=seq(-3,3,length=100)
y=dnorm(x,mean=0,sd=1)
plot(x,y,type="l")
x=seq(-2,2,length=100)
y=dnorm(x,mean=0,sd=1)
polygon(c(-2,x,2),c(0,y,0),col="red")
(pnorm(2))-pnorm(-2)
## [1] 0.9544997
I saw the below normalplot function later on so crerated the plots manually above.
Triathlon times, Part I (4.4, p. 142) In triathlons, it is common for racers to be placed into age and gender groups. Friends Leo and Mary both completed the Hermosa Beach Triathlon, where Leo competed in the Men, Ages 30 - 34 group while Mary competed in the Women, Ages 25 - 29 group. Leo completed the race in 1:22:28 (4948 seconds), while Mary completed the race in 1:31:53 (5513 seconds). Obviously Leo finished faster, but they are curious about how they did within their respective groups. Can you help them? Here is some information on the performance of their groups:
Remember: a better performance corresponds to a faster finish.
mean_m= 4313
sd_m=583
mean_w= 5261
sd_w=807
leo_zscore=(4948-mean_m)/sd_m
leo_zscore
## [1] 1.089194
mary_zscore=(5513-mean_w)/sd_w
mary_zscore
## [1] 0.3122677
Mary finished better as her Zscore is smaller.
a=1 - pnorm(4948, mean = 4313, sd = 583)
a*100
## [1] 13.80342
b=1 - pnorm(5513, mean = 5261, sd = 807)
b*100
## [1] 37.74186
Yes the Z score will change as the distribution will change and the area under the curve will change as well incase the distribution is long tailed or left/right skewed.
Heights of female college students Below are heights of 25 female college students.
\[ \stackrel{1}{54}, \stackrel{2}{55}, \stackrel{3}{56}, \stackrel{4}{56}, \stackrel{5}{57}, \stackrel{6}{58}, \stackrel{7}{58}, \stackrel{8}{59}, \stackrel{9}{60}, \stackrel{10}{60}, \stackrel{11}{60}, \stackrel{12}{61}, \stackrel{13}{61}, \stackrel{14}{62}, \stackrel{15}{62}, \stackrel{16}{63}, \stackrel{17}{63}, \stackrel{18}{63}, \stackrel{19}{64}, \stackrel{20}{65}, \stackrel{21}{65}, \stackrel{22}{67}, \stackrel{23}{67}, \stackrel{24}{69}, \stackrel{25}{73} \]
Yes here the area under the curve for Z score of 1,2,3 are 68.26,95.4,99.7 which follow the 68-95-99.7% rule.
pnorm((61.52+5.58), mean = 61.52, sd = 5.58)-pnorm((61.52-5.58), mean = 61.52, sd = 5.58) # 1 Std Dev away.
## [1] 0.6826895
pnorm((61.52+5.58*2), mean = 61.52, sd = 5.58)-pnorm((61.52-5.58*2), mean = 61.52, sd = 5.58) # 2 Std Dev away.
## [1] 0.9544997
pnorm((61.52+5.58*3), mean = 61.52, sd = 5.58)-pnorm((61.52-5.58*3), mean = 61.52, sd = 5.58) # 3 Std Dev away.
## [1] 0.9973002
# 2 Std Dev away.
No, the data appears normal as data are close to the slope line and is linear. 5
Defective rate. (4.14, p. 148) 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.
x1 = (1-0.02)^9 - 0.02
x1
## [1] 0.8137478
x2 = (1-0.02)^100
x2
## [1] 0.1326196
defect_1 = 1/.02
defect_1
## [1] 50
x3=sqrt((1-0.02)/0.02^2)
x3
## [1] 49.49747
defect_1 = 1/.05
defect_1
## [1] 20
x4=sqrt((1-0.05)/0.05^2)
x4
## [1] 19.49359
When probability incrrase, mean and SD decrease and vice versa.
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 couple plans to have 3 kids.
t = 3
n = 2
p = 0.51
boys=(p)*(p)*(1-p)*t
boys
## [1] 0.382347
b=(p)*(p)*(1-p)+(p)*(p)*(1-p)+(p)*(p)*(1-p)
b
## [1] 0.382347
There are many combinations now since the kids are 8 total and wil take much space and time.
Serving in volleyball. (4.30, p. 162) 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.
t = 10
n = 3
p = 0.15
serves = factorial(t-1)/(factorial(n-1)*factorial((t-1)-(n-1)))
prob= serves*(p^n)*(1-p)^(t-n)
prob
## [1] 0.03895012
.15
## [1] 0.15
As the trail are independent. So in b one attemp will not effect the other. While in a we are considering all posibilities.