# Questions

## Chicken and Egg

Recall in the Chicken-Egg problem that we have a chicken that lays eggs, where the number of eggs $$N$$ follows the distribution $$N\sim Pois(\lambda)$$. Given that the chicken lays $$N$$ eggs, the number of eggs that hatch $$X$$ follows the distribution $$X|N \sim Bin(N,p)$$.

{% tabs %}
{% tab title="Q" %}
Find $$E(X)$$
{% endtab %}

{% tab title="A" %}
Use Adam's Law!

$$
\begin{aligned}
E(X) &= E\[E(X|N)] = E\[Np] = p E\[N] =\lambda p
\end{aligned}
$$
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Q" %}
Find $$Var(X)$$
{% endtab %}

{% tab title="A" %}
Use Eve's Law!

$$
\begin{aligned}
Var(X) &= E\[Var(X|N)] + Var\[E(X|N)] \\
&= E\[Np(1-p)] + Var\[Np] \\
&= \lambda p(1-p) + p^2 \lambda \\
&= \lambda p
\end{aligned}
$$
{% endtab %}
{% endtabs %}

## Consumerism

When customers enter a particular store, each makes a purchase with probability $$p$$, independently. Given that a customer makes a purchase, the amount spent has mean $$\mu$$ (in dollars) and variance $$\sigma^2$$.

{% tabs %}
{% tab title="Q" %}
Find the mean of how much a random customer spends (note that the customer may spend nothing).
{% endtab %}

{% tab title="A" %}
Let $$X$$ be the amount a random customer spends at the store, and let $$I$$ be the indicator that a random customer makes a purchase. We then apply the Law of Total Expectation:

$$
\begin{aligned}
E\[X] &= E\[X | I= 0]P(I=0) \\&+ E\[X | I=1]P(I=1)\\
&= \mu p
\end{aligned}
$$
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Q" %}
Find the variance of how much a random customer spends (note that the customer may spend nothing).
{% endtab %}

{% tab title="A" %}
Let $$X$$ be the amount a random customer spends at the store, and let $$I$$ be the indicator that a random customer makes a purchase. We then apply the Law of Total Expectation:

$$
\begin{aligned}
E\[X^2] &= E\[X^2 | I=0]P(I=0) \\
&+ E\[X^2 | I=1]P(I=1) \\
&= E\[X^2 | I=1]P(I=1) \\
&= (\mu^2 + \sigma^2)p \\
Var\[X] &= E\[X^2] - E\[X]^2 \\
&= \sigma^2 p +\mu^2 p (1-p)
\end{aligned}
$$
{% endtab %}
{% endtabs %}

## Trapped Miners

A miner is trapped in a mine containing 3 doors. The first door leads to a tunnel that will take him to safety after 3 minutes. The other two doors lead to tunnels that will return him to the mine after 5 and 7 minutes of travel each. The miner is equally likely to choose any of the doors at any time.

{% tabs %}
{% tab title="Q" %}
What is the expected amount of time until he reaches safety?
{% endtab %}

{% tab title="A" %}
Let $$W$$ be the total amount of time taken until he reaches safety, and $$D\_1$$, $$D\_2$$, and $$D\_3$$ be the events of going through doors 1, 2, and 3 respectively.

Using LoTE, we have

$$
\begin{aligned}
E(W) &= E(W|D\_1)P(D\_1) + E(W|D\_2)P(D\_2) + E(W|D\_3)P(D\_3) \\
&= 3 \frac{1}{3} + (5 + E(W)) \frac{1}{3} + (7 + E(W)) \frac{1}{3} \\
\implies\frac{1}{3} E(W) &= 5 \\
E(W) &= 15\end{aligned}
$$
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://justinthezhu.gitbook.io/stat110/untitled-7/questions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
