n ## Exercise 1. Calculations and plots

As a sport analyst, you would like to calculate some probabilities for basketball player who is shooting guard.

n = 10 attemps and p = 0.7 the probability for scoring three-points

Calculate the following probabilities: P(X ≤ 3), P(X < 3), P(X > 4) and P(X = 7).

n = 10;
p = 0.7;


#P(X ≤ 3)
# cumulative function (pbinom) # lower true because from the left side of the graph.
pbinom(q=3, n, p, TRUE);
## [1] 0.01059208
fastGraph::shadeDist(
  xshade=3,
  ddist="dbinom",
  parm1=n,
  parm2=p,
  lower.tail = TRUE
  )

#P(X < 3)
pbinom(q=2, n, p, TRUE);
## [1] 0.001590386
fastGraph::shadeDist(
  xshade=2,
  ddist="dbinom",
  parm1=n,
  parm2=p,
  lower.tail = TRUE
  )

#P(X > 4)
pbinom(q=4, n, p, FALSE)
## [1] 0.952651
fastGraph::shadeDist(
  xshade=4,
  ddist="dbinom",
  parm1=n,
  parm2=p,
  lower.tail = FALSE
  )

#P(X = 7)
dbinom(7,n,p, FALSE)
## [1] 0.2668279
fastGraph::shadeDist(
  xshade = c(6,7),
  ddist = "dbinom",
  parm1=n,
  parm2=p,
  lower.tail = FALSE
)

## Exercise 2.

On a large fully automated production plant items are pushed to a side band at random time points, from which they are automatically fed to a control unit. The production plant is set up in such a way that the number of items sent to the control unit on average is 1.6 item pr. minute. Let the random variable X denote the number of items pushed to the side band in 1 minute.

  1. What is the probability that there will be more than 5 items at the control unit in a given minute is?

  2. What is the probability that less than 8 items arrive to the control unit within a 5-minute period?

## [1] 0.006040291
## [1] 0.5925473

0.0.1 Exercise 2. Plots.

Now let’s visualize:

# a)
a = 1.6 # item per minute
# x - number of items pushed to the side band in 1 minute
n = 5
shadeDist(n, a, lower.tail =  FALSE, ddist = "dpois") # eventually 1 - fun(x)

# b)
n = 8
period = 5
shadeDist(n, period*a, ddist = "dpois")

0.1 Exercise 3.(DIY)

In the manufacture of car engine cylinders, it’s known that there are 5 defective cylinders in every batch of 100 cylinders produced. From a production batch of 100 cylinders, 6 cylinders are selected randomly for analyzing.

What is the probability that the sample contains 2 defective cylinders?

sample_size = 6
prob_for = 2
wrong = 5/100
all = 100
result <- dhyper(prob_for, 5, 95, 6)
result
## [1] 0.02670642

0.1.1 Exercise 3. Plots.

Now let’s visualize:

fastGraph::shadeDist(
  xshade=2,
  parm1=c(5, 95),
  parm2=6,
  ddist = "dhyper",
  xmin = 2,
  xmax = 2,
  main = paste("The probability is: ", as.character(result))
)

0.2 Exercise 4.(DIY)

A company, which produces tires, is using new technology to provide safer driving experience to drivers. According to their claim, while speed is 70km/h, breaking distance of those tires have normal distribution with mean equal to 26.4 meters and sigma is equal to 2.34

According to standards, breaking distance shouldn’t be higher than 29 meters, while speed is 70 km/h.

  1. What is the probability of being comply with standards ?

  2. What is the probability of having breaking distance between 26 and 24 ?

# a)
# mean equal to 26.4 meters and sigma is equal to 2.34
v = 70
s = 29
pnorm(q=29, 26.4, 2.34, lower.tail = TRUE)
## [1] 0.8667397
shadeDist(29, parm1=26.4, parm2=2.34, lower.tail =TRUE)

# b)
pnorm(24, 26.4, 2.34, lower.tail = FALSE) - pnorm(26, 26.4, 2.34, lower.tail = FALSE)
## [1] 0.279605
shadeDist(c(24,26), parm1=26.4, parm2=2.34, lower.tail = FALSE)