**Question:** Suppose that the number of people who visit a yoga studio each day is a Poisson random variable with mean λ. Suppose further that each person who visits is, independently, female with probability p or male with probability 1−p. Find the joint probability that exactly n women and m men visit the academy today.

**Solution**: Dissecting the problem. I will try giving a brief explanation of the solution here. For a high detail of the problem, please refer to the text

- Notice that there a constraint on the sum itself but
*n*and*m*themselves could be variables given that they add up-to a number - The probability that we need can be denoted as follows
- P{N
_{1}=n, N2=m} = Σ P{N_{1}=n, N_{2}=n | N = i} P{N=i} - Then, the probability that P{N=i} is poisson distribution e
^{-λ}^{λn+m}⁄_{(n+m)!}

- P{N
- since there are two components to the poisson count, we need to introduce a binomial here and simplifying them we get two probabilities as
- P{N
_{1}=n} = e^{-λp}^{(λp)n}⁄_{n!} - P{N
_{2}=m} = e^{-λ(1-p)}^{(λ(1-p))m}⁄_{m!}

- P{N

**Simulations:** Approach to the simulations for this problem

- Pick an arbitrary λ for the Poisson Random Variate. Here I have chosen λ = 5
- The poisson outputs are numbers or the total number of people (male and female) visiting the yoga studio on a given day

- Pass these numbers into a function that divides the number into males and females
- For example, if the total number of people visiting the studio is 6, then this function would give the following combinations
- 0-Females & 6-Males
- 1-Females & 5-Males
- 2-Females & 4-Males
- 3-Females & 3-Males
- 4-Females & 2-Males
- 5-Females & 1-Males
- 6-Females & 0-Males

- For example, if the total number of people visiting the studio is 6, then this function would give the following combinations
- Then, we need to reformat the data to match the input format for the BarChart
- All the above has been done in code that has been presented below the charts

**Theoretical Probabilities with Special Cases**

- In the animations that follow, I have fixed the λ to be 25.
- Then, I have examined the cases where the total number of people is 20.
- This means that the 20 people could be formed from any one of the following cases
- N
_{females}= 0 and N_{males}= 20 - N
_{females}= 1 and N_{males}= 19 - N
_{females}= 2 and N_{males}= 18 - N
_{females}= 3 and N_{males}= 17 - N
_{females}= 4 and N_{males}= 16 - N
_{females}= 5 and N_{males}= 15 - N
_{females}= 6 and N_{males}= 14 - N
_{females}= 7 and N_{males}= 13 - N
_{females}= 8 and N_{males}= 12 - N
_{females}= 9 and N_{males}= 11 - N
_{females}= 10 and N_{males}= 10 - N
_{females}= 11 and N_{males}= 9 - N
_{females}= 12 and N_{males}= 8 - N
_{females}= 13 and N_{males}= 7 - N
_{females}= 14 and N_{males}= 6 - N
_{females}= 15 and N_{males}= 5 - N
_{females}= 16 and N_{males}= 4 - N
_{females}= 17 and N_{males}= 3 - N
_{females}= 18 and N_{males}= 2 - N
_{females}= 19 and N_{males}= 1 - N
_{females}= 20 and N_{males}= 0

- N
- We will look at these for the probability values from 0.1 to 0.9 in steps of 0.1
- so the probabilities would be {0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9}

**Code**

——————————

End of the post

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.