**Question:** You are invited to a party. Suppose the times at which invitees are entering the party is independent uniform (0,1) random variable. Suppose that, aside from yourself, the number of other people who are invited is a Poisson random variable with a mean of 10.

- Find the expected number of people who arrive before you
- Find the probability that you are the n
^{th} person to arrive

**Analytical Solution**

I would be only running a simulation for this one. But if you would like to get some hints about how to solve the problem, please refer to the other page in this blog called Order Statistics.

**Simulation Solution**

The following simulation has two elements to it. They are shown as smooth kernel histograms. The code for the simulation is also provided below in the code section. As you can see the density of the guests that have arrived *before you* is peaked at a different x-position.

*Note:* Smooth kernel histograms are inherently normalized so that they can be treated as a probability distribution functions. In this case, they are representing a smooth version of the discrete distribution created as a part of the simulation.

**Code**

The code is written completely in using Mathematica.

Module[
{guests = RandomVariate[PoissonDistribution[10], 10000],
simulation, plotData, plotDataSmooth},
plotData = {guests, simulation};
simulation =
Table[Length[
Select[RandomReal[{0, 1}, n - 1], # <= RandomReal[] &]], {n,
guests}];
SmoothHistogram[plotData, ImageSize -> 788, Frame -> True,
GridLines -> {Range[0, 25], Range[0, 0.25, 0.0125]},
AspectRatio -> 0.5,
PlotLegends -> Placed[{"Number of guests", "Number of guests that arrived earlier than you"}, Below],
PlotLabel -> Style[#, 20] &["Smooth Kernel Histograms of the scenario"]
]
]

End of the post 🙂

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

### Like this:

Like Loading...