A. Permutation and Combinations
- Harmony was born on 03/31/1983. How many eight-digit codes could she make using the digits in her birthday?
factorial(8)/(factorial(2)*factorial(3))
## [1] 3360
- A mother duck lines her 9 ducklings up behind her. In how many ways can the ducklings line up?
factorial(9)
## [1] 362880
- An incoming lot of siliicon 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 defective. Two waffers are to be selected randomly for inspection. Find the probability of the event: āNeither is defectiveā. Print the answer as decimal and fraction both. (Him: library(MASS), as.fractions())
library(MASS)
choose(16,2)/choose(20,2)
## [1] 0.6315789
as.fractions((choose(16,2)/choose(20,2)))
## [1] 12/19
B. Binomial Distribution Commands
- Ten coins are thrown simultaneously. Find the probabliity of getting at least sevent heads.
sum(dbinom(7:10, 10, .5))
## [1] 0.171875
- 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 three games out of five games played. What is the pmf of the distrubtion ?
1 - sum(dbinom(3:5, 5, .6))
## [1] 0.31744
- A coffee connoisseur 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) accepeted, (ii) rejected, when he does have the abilility he claims.
sum(dbinom(5:6, 6, 0.75)) #accepted
## [1] 0.5339355
1-(sum(dbinom(5:6, 6, 0.75))) #rejection
## [1] 0.4660645
C Normal Distribution Commands
- Suppose X has a normal distribution with mean = 25 and SD = 5.25. Find P(X<20)
pnorm(20, 25, 5.25)
## [1] 0.1704519
- Create a normal curve using the following steps (i)Create an array from -100 to 100 with a step-size .1. SUppose the name of the vector is āyā
y = seq(-100,100, by=.1)
- Assign z <- dnorm(y, mean = 25, sd = 5.25) # Creating the density function
z = dnorm(y, mean = 25, sd = 5.25)
- Plot the z curve against y
plot(z,y)

D Vector Operation
- Consider the given probability distributions
- create two arrays as āxā and āpā
x = c(-3, 6, 9)
p = c(1/6,1/2,1/3)
- Find the
E(X)
E = x%*%p # E(X)=x1p1+x2p2+...
E(X^2)
sum((x^2)*p)
## [1] 46.5
E((2X+1)^2)
sum((2*x+1)^2 *p)
## [1] 209
V(X)
sum(((x-E)^2)*p) # V(X) = E[(x-E(x))^2] = E[(x-MU)^2] where MU = E(x)
## Warning in x - E: Recycling array of length 1 in vector-array arithmetic is deprecated.
## Use c() or as.vector() instead.
## [1] 16.25
sigma(X)
sqrt(sum(((x-E)^2)*p)) #sqrt(V(X))
## Warning in x - E: Recycling array of length 1 in vector-array arithmetic is deprecated.
## Use c() or as.vector() instead.
## [1] 4.031129
V(2X+1)
sum((2*((x-E)^2)+1)*p)
## Warning in x - E: Recycling array of length 1 in vector-array arithmetic is deprecated.
## Use c() or as.vector() instead.
## [1] 33.5
y=(2*x+1)
sum(y)
## [1] 27
E Poisson Distribution
- Let X denotes a random variable that has a poisson distribution with mean lambda = 4. find the following probabilities
- P(X=5)
dpois(5, 4)
## [1] 0.1562935
- P(X<5)
sum(dpois(0:4, 4))
## [1] 0.6288369
- P(X>=5)
1 - sum(dpois(0:4, 4))
## [1] 0.3711631