Estan son las librerias usadas para el trabajo.

library(magrittr)
library("readxl")
library(ggplot2)
library(tibble)

Ejercicio #69.

Each of 12 refrigerators of a certain type has been returned to a distributor because of an audible, highpitched, oscillating noise when the refrigerators are running. Suppose that 7 of these refrigerators have a defective compressor and the other 5 have less serious problems. If the refrigerators are examined in random order, let X be the number among the first 6 examined that have a defective compressor.

options(scipen=999)
 # A. Calculate P(X=4) and P(x ≤ 4)
 ## P(X=4)
dhyper(x=4, m=7, k=6, n=5)
## [1] 0.3787879
## P(x ≤ 4)
 sum(dhyper(x=4:1, m=7, k=6, n=5))
## [1] 0.8787879
 # B. Determine the probability that X exceeds its mean value by more than 1 standard deviation.
 ln <- 12
 sqrt(sum((ln - 6)/ (ln - 1))*(3.5)*(1-(7/12)))
## [1] 0.8918826
 # C. Consider a large shipment of 400 refrigerators, of which 40 have defective compressors. If X is the
 # number among 15 randomly selected refrigerators that have defective compressors, describe a less
 # tedious way to calculate (at least approximately) P(X≤5) than to use the hypergeometric pmf.
 
 sum(pbinom(q=5, size=15, prob=0.1))
## [1] 0.9977503

Ejercicio #71.

A geologist has collected 10 specimens of basaltic rock and 10 specimens of granite. The geologist instructs a laboratory assistant to randomly select 15 of the specimens for analysis.

#a. What is the pmf of the number of granite specimens selected for analysis?
dhyper(x=5:10, m=10, k=15, n=10)
## [1] 0.01625387 0.13544892 0.34829721 0.34829721 0.13544892 0.01625387
#b. What is the probability that all specimens of one of the two types of rock are selected for analysis?
dhyper(x=5, m=10, k=15, n=10) + dhyper(x=5, m=10, k=15, n=10)
## [1] 0.03250774
#c. What is the probability that the number of granite specimens selected for analysis is within 1 standard deviation of its mean value?
N <- 20
 sqrt(sum((N - 15)/ (N - 1))*((15*10/N))*(1-(10/N)))
## [1] 0.9933993

Ejercicio #73.

Twenty pairs of individuals playing in a bridge tournament have been seeded 1, … , 20. In the first part of the tournament, the 20 are randomly divided into 10 east-west pairs and 10 north–south pairs.

#a. What is the probability that x of the top 10 pairs end up playing east–west?
#Para ello vamos a definir la probabilidad de que "X" parejas terminen dentro del top 10 estando en este - oeste como:
M <- 10
n <- 10
N <- 10
#Cuando x∈{0,1,2,3...10} habra probabilidad, fuera de este rango sera 0 
#Ejemplo con x = 10
dhyper(x=10, M, n, N)
## [1] 0.000005412544
#Ejemplo con x > 10
#Como vemos, la probabilidad sera 0
dhyper(x=89, M, n, N)
## [1] 0
#b. What is the probability that all of the top five pairs end up playing the same direction?

 dhyper(x=1,m=5,k=10,n=10)+  dhyper(x=1,m=5,k=10,n=10)
## [1] 0.03330003
#c. If there are 2n pairs, what is the pmf of X = the number among the top n pairs who end up playing east–west? What are E(X) and V(X)?

PMF de X = un numero entre las mejores n parejas que terminan jugando \((nx)(nn−x)/(2nn)\)

E(X) es \(nM/N\) y V(X) es \((N-n/N-1)nM/N(1-M/N)\)

Ejercicio #75.

The probability that a randomly selected box of a certain type of cereal has a particular prize is .2. Suppose you purchase box after box until you have obtained two of these prizes.

#a. What is the probability that you purchase x boxes that do not have the desired prize?
#Todo ronda dentro del valor de x, puede ser equivalente x = 0,1,2...
dnbinom(x=0, size=2, prob=0.2)
## [1] 0.04
#b. What is the probability that you purchase four boxes?
dnbinom(x=2, size=2, prob=0.2)
## [1] 0.0768
#c. What is the probability that you purchase at most four boxes?
sum(dnbinom(x=0:2, size=2, prob=0.2))
## [1] 0.1808
#d How many boxes without the desired prize do you expect to purchase? How many boxes do you expect to purchase?
r <- 2
p <- 0.2
#E(X) + r= (r*(1-p))/2
numero <- (r*(1-p))
numero/0.2 + r
## [1] 10

Ejercicio #77.

Three brothers and their wives decide to have children until each family has two female children. What is the pmf of X 5 the total number of male children born to the brothers? What is E(X), and how does it compare to the expected number of male children born to each brother?

# X = the total number of male children born to the brothers? What is E(X)?

\(^{x-1}C_{6-1}(0.5)^{6}(1-0.5)^{x-6}\)

#how does it compare to the expected number of male children born to each brother 
y <- 100*pnbinom(q=1, size=6, prob=0.5)
print(floor(y))
## [1] 6

Fin del trabajo.