A permutation and Combination

  1. Harmony was born on 03/31/1983. How many eight-digit codes could she make using the digits in her birthday?
factorial(8)/(factorial(3)*factorial(2))
## [1] 3360
  1. A mother duck lines her 9 ducklings up behind her. In how many ways can the ducklings line up?
factorial(9)
## [1] 362880
  1. An incoming lot of silicon wafers is to be inspected for defective ones by an engineer in a microchip manufacturing plant. Suppose that in a tray containing 20 wafers 4 are defectiv. Two wafers are to be selected radomly for inspection. Find the probabilityof the event: “Neither is defective”. Print the answer as decimal and fraction both.
choose(16,2)/choose(20,2)
## [1] 0.6315789
library(MASS)
as.fractions(choose(16,2)/choose(20,2))
## [1] 12/19

B. Binomial Distribution Commands

  1. Ten coins are thrown simultaniuosly. Find the probability of getting at least seven heads.
sum(dbinom(7:10, 10, 0.5))
## [1] 0.171875
  1. A and B play game in which their chances of winning are in the ratio 3:2. Find A’s chance of winning at least 3 games out of five games played. What is the pmf of the distribution?
sum(dbinom(3:5,5,.6))
## [1] 0.68256
  1. A coffee conoisser claims that he can distinguish between a cup of instant coffee and a cup of percolator coffee 75% of the time. It is agreed that his claim will be accepted if he correctly identifies at least 5 of the 6 cups. Find his chances of having the claim (i) accepted, (ii) rejected, when he does have the ability he claims.
sum(dbinom(5:6, 6, 0.75)) # accepted
## [1] 0.5339355
1- sum(dbinom(5:6, 6, 0.75)) # rejected
## [1] 0.4660645

C. Normal Distribution Commands

  1. Suppose X has a normal distribution with mean = 25 and SD = 5.25. Find P(X<20)
x <- pnorm(20, 25, 5.25)
x
## [1] 0.1704519
  1. Create a normal curve using the following steps
  1. Create an array from -100 to 100 with a step-size 0.1. Suppose the name of the vector is “y”
  2. Assign z <- dnorm(y, mean = 25, sd = 5.25) # creating the density function
  3. Plot the z curve against y.
y <- c(-100:100, by = 0.1)
z <- dnorm(y, 25, 5.25)
plot(y,z,type = "o", col = "red") 

D. Vector Operation

  1. Consider the given probability distribution: x=-3,6,9. p=1/6, 1/2, 1/3.
  1. Create two arrays as “x” and “p”
  2. Find the
    1. E(X)
    2. E(X^2)
    3. E((2X+1)^2)
    4. V(X)
    5. Theta(X)
    6. V(2X+1)
x <- c(-3,6,9)
p <- c(1/6, 1/2, 1/3)
h <- sum(x*p)
#a
# sum(x*p) is the same as (x%*%p)
sum(x*p)
## [1] 5.5
#b
sum(((x)^2)*p)
## [1] 46.5
#c
sum(((2*x+1)^2)*p)
## [1] 209
#d
sum((((x)-h)^2)*p)
## [1] 16.25
#e
(sum((x-h)*p))^(1/2)
## [1] 0
#f
(sum(((2*x+1)-h)*p))^(1/2)  
## [1] 2.54951

Poisson Distribution

  1. Let X denotes a random variable that has a poisson distribution with mean \(\lambda\)=4. Find the following probabilities.
  1. P(X=5)
  2. P(X<5)
  3. P(X>=5)
# a
dpois(5,4)
## [1] 0.1562935
# b
sum(dpois(0:4,4))
## [1] 0.6288369
#c
1-sum(dpois(0:4,4))
## [1] 0.3711631