Number of permutations with fixed first and last places If I have 3 males and 2 females lining up at a grocery store, how many different ways can they line up if the first person in line is female and the last person in line is male?
Is it as simple as 2x3x2x1x4?
 A: General rule for the probability of an intersection of events. Maybe consider the following two steps. 
(a) $P(\mathrm{First\; in\; line\; is\; woman}) = 2/5$ and
$P(\mathrm{Last\; in\; line\; is\; man}\,|\,\mathrm{First\; in\; line\; is\; woman}) = 3/4.$
(b) Use $P(A \cap B) = P(A)P(B|A).$

Simulation. Do a simulation in R. 


*

*The the population ('pop') consists
of three men (1's) and two women (2's). 

*Use the 'sample' function
to randomly scramble the population. 

*Next, check to see if it is
TRUE that the first in 'line' is a woman and the last is a man.

*Finally, when you finish the loop to look at a million lines,
the logical vector 'event' has a million TRUEs and FALSEs, and
the 'mean' of 'event' is the proportion of TRUEs in 'event'. 


A million events should be enough to approximate the answer to
two or three decimal places.
set.seed(2020)     # for reproducibility
pop = c(1,1,1,2,2)
m = 10^6;  event=logical(m)
for (i in 1:m) {
  line = sample(pop)
  event[i] = (line[1]==2 & line[5]==1) 
  }
mean(event)
[1] 0.30028

