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
  1. z>-1.13
1 - pnorm(-1.13, mean = 0, sd = 1)
## [1] 0.8707619
normalPlot(mean = 0, sd = 1, bounds = c(-1.13, 4))

  1. Z < 0.18
pnorm(.18, mean = 0, sd = 1)
## [1] 0.5714237
normalPlot(mean = 0, sd = 1, bounds = c(-4, .18), tails = FALSE)

  1. Z > 8
1 - pnorm(8, mean = 0, sd = 1)
## [1] 6.661338e-16
normalPlot(mean = 0, sd = 1, bounds = c(8, Inf), tails = FALSE)

  1. |Z| < 0.5
x <- 1 - pnorm(.5, mean = 0, sd = 1)
y <- pnorm(.5, mean = 0, sd = 1)
print(x)
## [1] 0.3085375
print(y)
## [1] 0.6914625
normalPlot(mean = 0, sd = 1, bounds = c(x, y), tails = FALSE)

b)

Z_scores_Leo <- (4948 - 4313) / 583
Z_scores_Leo
## [1] 1.089194
Z_scores_Mary <- (5513 - 5261) / 807
Z_scores_Mary
## [1] 0.3122677
normalPlot(0, 1, c(1.09, Inf))

e)

normalPlot(0, 1, c(0.31, Inf))

heights <- c(54,55,56,56,57,58,58,59,60,60,61,61,62,62,63,63,63,64,65,65,67,67,69,73)
summary(heights)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   54.00   58.00   61.50   61.58   64.25   73.00
heightmean <- mean(heights)
heightsd <- sd(heights)
hist(heights, probability = TRUE, ylim = c(0, 0.11),col="yellow")
x <- 50:75
y <- dnorm(x = x, mean = heightmean, sd = heightsd)
lines(x = x, y = y, col = "brown")

qqnorm(heights, col="lightsteelblue")
qqline(heights, col="darkblue")

a.

pgeom(10-1,0.02)
## [1] 0.1829272
1-pgeom(100,0.02)
## [1] 0.1299672
p <- .02
e <- 1/p
e
## [1] 50
sd <- sqrt((1 - p)/p^2)
sd
## [1] 49.49747
boy <- .51
n <- 3
x <- 2
dbinom(x, n, boy)
## [1] 0.382347
probboys <- ((.49*.51*.51)+(.51*.49*.51)+(.51*.51*.49))
probboys
## [1] 0.382347
p <- .15
n <- 10
k <- 3
choose(n - 1, k - 1) * (1 - p)^(n - k) * p^k
## [1] 0.03895012