Discrete Distribution

Problem Statement 1

A quality control inspector randomly samples 25 products from a production line and counts the number of defective products in the sample.  Suppose it is known that the probability any one product is defective is 0.12

a.Plot the probability distribution

plot(x=0:25,dbinom(x=0:25,size=25,prob=.12))

b. What is the probability that there are exactly 3 defective products in the sample?

dbinom(3,25,.12)
## [1] 0.2387209

c. What is the probability there are more than 3 defective products in the sample?

pbinom(3,25,.12)
## [1] 0.647537

Problem statement 2

1.The arrival of customers to a queue follows a Poisson process with an average rate of 14.25 per hour. 

a. Plot the probability distribution from 10 to 20

plot(x=10:20,dpois(x=10:20, lambda=14.25))

b. What is the probability that exactly 14 customers will arrive in the next hour?

dpois(14,14.25)
## [1] 0.1057556

c. What is the probability that there will be less than 12 customers who arrive in the next hour?

ppois(12,14.25)
## [1] 0.3343031

Continuous Distribution in R

1.A particular random variable is normally distributed with a mean of 20 and a standard deviation of 2.5.

a. plot the probability density function of X for all x between 10 and 30, be sure to add a title and label to the axes 

curve(dnorm(x,20,2.5),from=10, to=30,main= "pdf of Normal", xlab="xlab", ylab="y")

b. plot the cumulative density function of X for all x between 0 and 25, be sure to add a title and label to the axes

curve(pnorm(x,20,2.5),from=10, to=30,main= "cdf of Normal", xlab="xlab", ylab="y")

c. Find the probability X<19.73

dnorm(19.73,20,2.5)
## [1] 0.158649

d.Find the probability 18.5<X<19.73

pnorm(19.73,20,2.5)-pnorm(18.5,20,2.5)
## [1] 0.1827447

Problem Statement 2

2. A particular random variable is exponentially distributed with a mean of 5 (recall: E[X]=1/rate)

a. plot the probability density function of X for all x between 0 and 25, be sure to add a title and label to the axes

curve(dexp(x,1/5),from=0, to=25,main="Exp", xlab="xlab", ylab="y")

b. plot the cumulative density function of X for all x between 0 and 25, be sure to add a title and label to the axes

curve(pexp(x,1/5),from=0, to=25,main="Exp", xlab="xlab", ylab="y")

c.Find the probability X<10.27

pexp(10.27,1/5)
## [1] 0.871779

d.Find the probability 3.84<X<10.27

pexp(10.27,1/5)-pexp(3.84,1/5)
## [1] 0.335719

Problem Statement 3

3. A particular random variable is gamma distributed with a shape parameter of 2.3 and a scale parameter of 8.4 (be sure to set parameters correctly in R)

a.plot the probability density function of X for all x between 0 and 50, be sure to add a title and label to the axes

curve(dgamma(x,2.3,1/8.4),from=0,to=50, main="gamma", xlab="x", ylab="y")

b. plot the cumulative density function of X for all x between 0 and 50, be sure to add a title and label to the axes

curve(pgamma(x,2.3,1/8.4),from=0,to=50, main="gamma", xlab="x", ylab="y")

c.Find the probability X<27.4

pgamma(27.4,2.4,1/8.4)
## [1] 0.7618589

d. Find the probability 17.3 <X<27.4

pgamma(27.4,2.4,1/8.4)-pgamma(17.3,2.4,1/8.4)
## [1] 0.2665412