3.37 Exploring combinations.

The formula for the number of ways to arrange n objects is n! = n * (n ??? 1) * · · · * 2 * 1. This exercise walks you through the derivation of this formula for a couple of special cases. A small company has five employees: Anna, Ben, Carl, Damian, and Eddy. There are five parking spots in a row at the company, none of which are assigned, and each day the employees pull into a random parking spot. That is, all possible orderings of the cars in the row of spots are equally likely.

  1. On a given day, what is the probability that the employees park in alphabetical order?

Answer: If we are choosing the parking lot in an alphabetical order, then there will be one straight pattern. 5 cars parked in 5 places.

So, it can be denoted as 5!.

factorial <- factorial(5)
probability <- 1/factorial

print(probability)
## [1] 0.008333333

The probabilty is 0.8333%

  1. If the alphabetical order has an equal chance of occurring relative to all other possible orderings, how many ways must there be to arrange the five cars?

Answer: Since there are 5 cars and 5 places, you can find it by just finding the 5!

random_order_parking <- factorial(5)

print(random_order_parking)
## [1] 120
  1. Now consider a sample of 8 employees instead. How many possible ways are there to order these 8 employees’ cars?

Answer: If there are 8 employees,then we can find the factorial of 8!

factorial = factorial(8)

print(factorial)
## [1] 40320