Sheldon Ross 10: Exercise 3.44

Question: The number of customers entering a store on a given day is Poisson distributed with mean λ = 10. The amount of money spent by a customer is uniformly distributed over (0, 100). Find the mean and variance of the amount of money that the store takes in on a given day.


Analytical Solution

Calculation-wise, this is straightforward

  1. Expectation: As seen from the question, the variables are independent and hence, the expectation of the product is the product of the expectations which is λ*50 = 1*50 = 500
  2. Variance: This can be derived from the following formula. The variance is simply the sum of the following two quantities
    • Expected Number of Customers Per Day * Variance of the amount spent per day by a customer
    • Square of the expectation of the Number of Customers Per day * Variance of the amount spent  per day by the customer
    • This means the variance is $33,333
  3. Details on the calculation from step 2

Simulation Solution

With a few lines of the code, we can simulate this scenario, I have shown the same simulation with 5 kinds of “ChartElementFunction” to give a general idea about the quantiles. Notice the asymmetry in the distributions. Can you guess why? (Psst. It’s because of one of the distributions in the problem I will let you figure out which one)


Code

I used slot operators to condense the code. Take your time to break it down further if needed.

Module[
  {
    customers := RandomVariate[PoissonDistribution[10]],
    spending := RandomVariate[UniformDistribution[{0, 100}]],
    simulation,
    mean,
    variance
  },

  simulation =
      Table[
        Plus @@ (spending & /@ Range[customers]), 1000, 100];
  mean = Mean /@ simulation;
  variance = Variance /@ simulation;

  Column[
    Table[
      Labeled[
        Framed[
          Row[
            MapThread[
              DistributionChart[#1,
                ChartElementFunction -> chartElementFunction,
                ImageSize -> 394, AspectRatio -> 0.35, PlotLabel -> #2,
                PlotRange -> All] &,
              {{mean, variance}, {"Mean:\[Mu]", "Variance:\!\(\*SuperscriptBox[\(\[Sigma]\), \(2\)]\)"}}]]],
        Rotate[chartElementFunction, Divide[Pi, 2]], Left],
      {chartElementFunction, {"PointDensity", "SmoothDensity", "GlassQuantile", "BoxWhisker", "HistogramDensity"}}
    ]
  ]
]

End of the post 🙂


.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.