library(DATA606)
## Loading required package: shiny
## Loading required package: openintro
## Please visit openintro.org for free statistics materials
##
## Attaching package: 'openintro'
## The following objects are masked from 'package:datasets':
##
## cars, trees
## Loading required package: OIdata
## Loading required package: RCurl
## Loading required package: bitops
## Loading required package: maps
## Loading required package: ggplot2
##
## Attaching package: 'ggplot2'
## The following object is masked from 'package:openintro':
##
## diamonds
## Loading required package: markdown
##
## Welcome to CUNY DATA606 Statistics and Probability for Data Analytics
## This package is designed to support this course. The text book used
## is OpenIntro Statistics, 3rd Edition. You can read this by typing
## vignette('os3') or visit www.OpenIntro.org.
##
## The getLabs() function will return a list of the labs available.
##
## The demo(package='DATA606') will list the demos that are available.
##
## Attaching package: 'DATA606'
## The following object is masked from 'package:utils':
##
## demo
3.2 Area under the curve
What percent of a standard normal distribution N(μ=0,σ=1) is found in each region? Be sure to draw a graph.
normalPlot(mean = 0, sd = 1, bounds = c(-1.13, Inf))
So the area under the curve is .871
normalPlot(mean = 0, sd = 1, bounds = c(-Inf, 0.18))
So the area under the curve is .571
normalPlot(mean = 0, sd = 1, bounds = c(8, Inf))
So the area under the curve is 6.66e-16, which is approximately 0.
normalPlot(mean = 0, sd = 1, bounds = c(-.5, .5))
So the area under the curve is .383
3.4 Triathlon times
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:
The finishing times of the Men, Ages 30 - 34 group has a mean of 4313 seconds with a standard deviation of 583 seconds. The finishing times of the Women, Ages 25 - 29 group has a mean of 5261 seconds with a standard deviation of 807 seconds. The distributions of finishing times for both groups are approximately Normal. Remember: a better performance corresponds to a faster finish.
Men 30-34: N(μ=4313,σ=583) Women 25-29: N(μ=5261,σ=807)
Leo’s Z-score (4948-4313)/(807) = 1.0892
Mary’s Z-score: (5513-5261)/(807) = .3123
For Mary’s group, she did better than Leo did for his respective group.
Mary ranked better because she has the lower z-score, therefore she has the lower time for her group.
(1-pnorm(1.0892))
## [1] 0.1380328
The percent of the triathletes Leo finished faster than is 13.80328%
(1-pnorm(.3123))
## [1] 0.3774063
The percent of the triathletes Leo finished faster than is 37.74063%
Yes, because we based our calculations and comparisons based off the assumption that the distributions were normal.
3.18 Heights of female college students Below are heights of 25 female college students.
heights <- 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)
htmean <- c(61.52)
htstd <- c(4.58)
one <- heights[heights > htmean - htstd & heights < htmean + htstd]
a <- length(one)/length(heights)
two <- heights[heights > htmean - 2*htstd & heights < htmean + 2*htstd]
b <- length(two)/length(heights)
three <- heights[heights > htmean - 3*htstd & heights < htmean + 3*htstd]
c <- length(three)/length(heights)
p <- c(a, b, c)
p
## [1] 0.68 0.96 1.00
The heights do follow the 68-95-99.7% Rule, appoximately.
qqnormsim(heights)
There are a few outliers, but the distribution appears to be relatively normal.
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.
((.98)^(9))*(.02)
## [1] 0.01667496
the probability that the 10th transistor is the first with a defect is .01667496
(.98)^(100)
## [1] 0.1326196
The probability that the machine produces no defective transistors in a batch of 100 is 0.1326196
I would expect 50 transistors to be produced before the first with a defect.
σ = (p/((1 - p)2))(1/2) = ((.02)/(.98*.98))^(1/2) = .1443
the standard deviation is .1443.
μ = 1/p = 1/(.05) = 20 transistors
I would expect 20 transistors to be produced before the first with a defect.
σ = (p/((1 - p)2))(1/2) = ((.05)/(.95*.95))^(1/2) = .23537557657
the standard deviation is approximately .235
The wait time for a defective transistor decreases and the probability of there being a defective transistor increases.
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 couple plans to have 3 kids.
((.51)^(2))*(.49)*choose(3, 2)*choose(1, 1)
## [1] 0.382347
The probability that two of them will be boys is 0.382347.
P(BBG | BGB | GBB) = (.51.51.49) + (.51.49.51) + (.49.51.51) = (.127449)(3) = 0.382347. a) and b) are the same probability.
There are many more combinations to have 8 kids and 3 of them be boys, so writing out all C(8,3)=56 ways would be very tedious.
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.
So the first 9 times can go any which way, but must include two succesful serves, so it is calculated as C(9,2)(.15)^(2). The tenth serve can go only one way, so it is calculated (.15)(1).
choose(9, 2)*((.15)^(3))
## [1] 0.1215
So there is a 0.1215 chance the tenth serve with be the third successful serve.
Since the events are independent, the probability that her 10th serve will be successful is .15
Part a) asks for a combination of independent outcomes whereas b) asks for just one independent outcome.