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, Part II. What percent of a standard normal distribution N(μ = 0, sigma = 1) is found in each region? Be sure to draw a graph.
normalPlot(mean = 0, sd = 1, bounds = c(-1.13, Inf))
normalPlot(mean = 0, sd = 1, bounds = c(-Inf,0.18))
normalPlot(mean = 0, sd = 1, bounds = c(8,Inf))
normalPlot(mean = 0, sd = 1, bounds = c(-.5,.5))
3.4 Triathlon times, Part I. 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.
Write down the short-hand for these two normal distributions.
Men: N(mu = 4313, sigma = 583)
Women: N(mu = 5261, sigma = 807)
What are the Z-scores for Leo’s and Mary’s finishing times? What do these Z-scores tell you?
leoZscore <- (4948-4313)/583
leoZscore
## [1] 1.089194
maryZscore <- (5513-5261)/807
maryZscore
## [1] 0.3122677
#The Z-scores tell us how far away Leo and Mary's finishing times are away from the mean
Did Leo or Mary rank better in their respective groups? Explain your reasoning.
Mary ranked better because she has a smaller Z-score. Thus, her finishing time is closer to the mean finishing time of her group.
What percent of the triathletes did Leo finish faster than in his group?
pnorm(leoZscore, lower.tail = FALSE)
## [1] 0.1380342
pnorm(maryZscore, lower.tail = FALSE)
## [1] 0.3774186
If the distributions of finishing times are not nearly normal, would your answers to parts (b) - (e) change? Explain your reasoning.
Answers to parts b-e would probably change because calculations would be performed based on a different distribution.
3.18 Heights of 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)
heightsMean <- 61.52
heightsSd <- 4.58
oneSd <- subset(heights, heights > heightsMean - heightsSd & heights < heightsMean + heightsSd)
percent68 <- length(oneSd)/length(heights)
percent68
## [1] 0.68
twoSd <- subset(heights, heights > heightsMean - 2*heightsSd & heights < heightsMean + 2*heightsSd)
percent95 <- length(twoSd)/length(heights)
percent95
## [1] 0.96
threeSd <- subset(heights, heights > heightsMean - 3*heightsSd & heights < heightsMean + 3*heightsSd)
percent99.7 <- length(threeSd)/length(heights)
percent99.7
## [1] 1
#The heights approximately follow the Empirical Rule
Do these data appear to follow a normal distribution? Explain your reasoning using the graphs provided below.
The data nearly follows a normal distribution. There is some deviation in the tails.
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.
(1-.02)^9*.02
## [1] 0.01667496
.98^100
## [1] 0.1326196
1/.02
## [1] 50
var <- (1-0.02)/(0.02^2)
var
## [1] 2450
sd <- sqrt(var)
sd
## [1] 49.49747
#Number of Transistors produced before first defect:
1/0.05
## [1] 20
var <- (1-0.05)/(0.05^2)
var
## [1] 380
sd <- sqrt(var)
sd
## [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 of an event decreases the mean and standard deviation of wait time until success.
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.
3*(.51^2)*(1-.51)
## [1] 0.382347
#BBG, BGB, GBB
(.51^2*.49)+(.51*.49*.51)+(.49*.51^2)
## [1] 0.382347
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).
Calculating the probability that a couple who plans to have 8 kids will have 3 boys would involve many more possible sequences (8C3), so using the approach from part b would be mouch more tedious than using the formula.
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.
library("combinat")
##
## Attaching package: 'combinat'
## The following object is masked from 'package:utils':
##
## combn
p <- .15
k <- 3
n <- 10
choose(n-1, k-1) * p^k * (1-p)^(n-k)
## [1] 0.03895012
Suppose she has made two successful serves in nine attempts. What is the probability that her 10th serve will be successful?
The probability that her 10th serve is successful is 15% because each serve is independent
Even though parts (a) and (b) discuss the same scenario, the probabilities you calculated should be different. Can you explain the reason for this discrepancy?
In part a we are calculating the probability she makes her 3rd sucessful serve on her 10th attempt, which fits the negative binomial model. This differs from part b where we are only asked the probabilty that her 10th serve is successful, which is independent of her previous attempts.