diff --git a/.DS_Store b/.DS_Store index 5e131bb..d0cb6b4 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/Data/SimulatedDataGroupProjectDynamics.ipynb b/Data/SimulatedDataGroupProjectDynamics.ipynb index e6485e2..51802ef 100644 --- a/Data/SimulatedDataGroupProjectDynamics.ipynb +++ b/Data/SimulatedDataGroupProjectDynamics.ipynb @@ -195,7 +195,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -216,7 +216,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -225,10 +225,10 @@ "$\\hat{y} = 4.712 +0.227 x_{1}$" ], "text/plain": [ - "" + "" ] }, - "execution_count": 15, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -246,7 +246,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -256,7 +256,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -265,10 +265,10 @@ "$\\hat{y} = 0.047 +1.491 x_{1}$" ], "text/plain": [ - "" + "" ] }, - "execution_count": 11, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -279,7 +279,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -288,10 +288,10 @@ "$\\hat{y} = 0.056 +0.659 x_{1}$" ], "text/plain": [ - "" + "" ] }, - "execution_count": 12, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -302,7 +302,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 12, "metadata": {}, "outputs": [ { diff --git a/book/.DS_Store b/book/.DS_Store index 15b21c8..9ae806e 100644 Binary files a/book/.DS_Store and b/book/.DS_Store differ diff --git a/book/_build/.doctrees/bayes.doctree b/book/_build/.doctrees/bayes.doctree index 90732aa..daf0a82 100644 Binary files a/book/_build/.doctrees/bayes.doctree and b/book/_build/.doctrees/bayes.doctree differ diff --git a/book/_build/.doctrees/environment.pickle b/book/_build/.doctrees/environment.pickle index ed5bd54..b998e39 100644 Binary files a/book/_build/.doctrees/environment.pickle and b/book/_build/.doctrees/environment.pickle differ diff --git a/book/_build/.doctrees/probability.doctree b/book/_build/.doctrees/probability.doctree index db95dfc..47878aa 100644 Binary files a/book/_build/.doctrees/probability.doctree and b/book/_build/.doctrees/probability.doctree differ diff --git a/book/_build/html/_sources/bayes.md b/book/_build/html/_sources/bayes.md index 9d81ff1..0abe987 100644 --- a/book/_build/html/_sources/bayes.md +++ b/book/_build/html/_sources/bayes.md @@ -122,6 +122,107 @@ name: bayesTest $$\mathbb{P}(Q \mid \cdot U) = \frac{\mathbb{P}(QU)}{\mathbb{P}(\cdot U)}$$ -$\mathbb{P}(\cdot U)$ is found by summing the probability for each of the paths that terminate in $U$. This is $\frac{1}{26} + \frac{25}{676}$. +$\mathbb{P}(\cdot U)$ is found by summing the probability for each of the paths that terminate in $U$. This is $\frac{1}{26} + \frac{25}{676}$, -$$\mathbb{P}(Q \mid \cdot U) = \frac{\frac{1}{26}}{\frac{1}{26} + \frac{25}{676}} = \frac{26}{51}$$ +$$\mathbb{P}(Q \mid \cdot U) = \frac{\frac{1}{26}}{\frac{1}{26} + \frac{25}{676}} = \frac{26}{51}.$$ + + +## Exercises + +```{exercise-start} +:label: boxes +``` + +A box contains two tickets, labeled $H$ or $T$. There is a 25% chance the box contains two $H$s. There is a 25% chance the box contains two $T$s. There is a 50% chance the box contains one $H$ and one $T$. + +1. What is the chance of drawing an $H$? + +2. Suppose you draw an $H$. What is the chance that the box contained two $T$s? + +3. Suppose you draw an $H$. What is the chance that the box contained two $H$s? + +4. After replacing the $H$, what is the chance of selecting another $H$? + +```{exercise-end} +``` + +```{exercise-start} +:label: bayesraredisease +``` +Consider a rare disease that affects 1 in 10,000 people in a population. A medical test for the disease has a 99% chance of correctly identifying a diseased person (true positive) and a 99% chance of correctly identifying a non-diseased person (true negative). + +If a person from this population tests positive for the disease, what is the probability that they actually have the disease? + +Given: + +$$\mathbb{P}(\text{Disease}) = \frac{1}{10,000}$$ + +$$\mathbb{P}(\text{No disease}) = 1 - \mathbb{P}(D)$$ + +$$\mathbb{P}(\text{Positive} | \text{Disease}) = 0.99$$ + +$$\mathbb{P}(\text{Negative} | \text{No Disease}) = 0.99$$ +```{exercise-end} +``` + + +```{exercise-start} +:label: hatcoins +``` + +You're playing basketball at the park when your team picks up an unknown player. The unknown player is equally likely to be a scrub or a baller. A baller makes 90% of their shots and each shot is independent. A scrub makes 10% of their shots and each shot is independent. + +1. What is the chance an unknown makes their first shot? +2. What is the chance that the player makes their second shot if they made their first? +3. Are the first and second shot outcomes independent from *your* perspective? + + +```{exercise-end} +``` + + +```{exercise-start} +:label: troll +``` + +A pilgrim, traveling home, is wandering through a strange land when a troll appears: + +> *Woe, to pass, pilgrim choose of these doors two.
Which is which, I cannot reveal to you.
Home with chance 7 or 73.
It depends on your choice and fate's decree.
Independent but certainty you lack.
Take now two draws before I turn thee back.* + +1. What is the probability the pilgrim opens a door that leads home on the first draw? + +2. The troll, old in his years, has seen 200 million other pilgrims pass through. Each has chosen a door randomly to start and then the other door second if the first didn't take them home. Finish filling in the table below with the expected counts. + +| | Door 7 second | Door 73 second | Home after first | +|-------------------|---------------|----------------|------------------| +| Door 7 first | 0 million | | | +| Door 73 first | | 0 million | 73 million | + +3. If the first draw does not lead home, what is the probability the pilgrim opened the door that leads home with chance 7%? What is the probability the pilgrim opened the door that leads home with chance 73%? + +4. If the first draw does not lead home, should the pilgrim open a different door on the next draw or try the same door again? Or does it not matter? + +5. What is the probability that the pilgrim remains in exile? + +6. The pilgrim, alarmed by the risk of remaining in exile, bargains with the troll to replace the two doors with one 40% chance door. This averages the chances. Is this wise? + +```{exercise-end} +``` + +```{exercise-start} +:label: bayesReview +``` + +Suppose that a product is sold on Amazon and it has either high quality ($H$) or low quality ($L$). We observe a single product review, which can either be good or bad. Reviewers can be of two types: fake or truth-teller. A fake reviewer always leaves a positive review, regardless of the product quality. A truth-teller reviewer leaves a positive review when the product is high quality and leaves a negative review if the product is low quality. + +Assume $\mathbb{P}(H) = \frac{1}{2}$ and that each type of reviewer is equally likely. + +- a.) What is $\mathbb{P}(\text{good review})$? +- b.) What is $\mathbb{P}(\text{good review} \mid H)$? +- c.) What is $\mathbb{P}(H \mid \text{good review})$? +- d.) Draw a probability tree that summarizes the probabilities based on product quality, review type, and reviewer type. +- e.) Are the events of "high quality product" and "good review" independent or dependent? Explain. +- f.) Suppose the truth-teller is replaced by a joker who leaves a negative review if the product is high quality and a positive review if the product is low quality. What is $\mathbb{P}(H \mid \text{bad review})$? + +```{exercise-end} +``` \ No newline at end of file diff --git a/book/_build/html/_sources/probability.md b/book/_build/html/_sources/probability.md index d34670d..f9475d2 100644 --- a/book/_build/html/_sources/probability.md +++ b/book/_build/html/_sources/probability.md @@ -333,8 +333,7 @@ $$ \frac{n!}{k!(n-k)!} p^k (1-p)^{n-k}.$$ Think of $p^k (1-p)^{n-k}$ as the probability of a sequence of $k$ heads followed by $n-k$ tails. The binomial coefficient in front then adjusts that probability to allow for all of the other ways to get $k$ heads–$n-k$ tails followed by $k$ heads for example. This only works for coin flips or similar processes where the individual trials are independent and the probability of a heads or some substitutable event of interest is the same from one trial to the next. These trial outcomes are said to be *independent and identically distributed*, or *iid*. -**Example** -A trick coin comes up heads with probability $p = \frac{2}{3}$. Out of four flips, what is the probability of two heads? +**Example**: A trick coin comes up heads with probability $p = \frac{2}{3}$. Out of four flips, what is the probability of two heads? ```{dropdown} Two heads @@ -355,6 +354,7 @@ $$ 4\cdot \frac{8}{27}\cdot\frac{1}{3} + \frac{16}{81} = \frac{48}{81} = \frac{1 ``` + ## Exercises ```{exercise-start} diff --git a/book/_build/html/bayes.html b/book/_build/html/bayes.html index a382476..9213230 100644 --- a/book/_build/html/bayes.html +++ b/book/_build/html/bayes.html @@ -426,6 +426,7 @@

Contents

+
  • Exercises
  • @@ -527,12 +528,114 @@

    Bayes Theorem with TreesFig. 42 can help us find the probability that a word starts with \(Q\), given that the second letter is \(U\). Maybe that’s helpful if you’re on Wheel of Fortune.

    \[\mathbb{P}(Q \mid \cdot U) = \frac{\mathbb{P}(QU)}{\mathbb{P}(\cdot U)}\]
    -

    \(\mathbb{P}(\cdot U)\) is found by summing the probability for each of the paths that terminate in \(U\). This is \(\frac{1}{26} + \frac{25}{676}\).

    +

    \(\mathbb{P}(\cdot U)\) is found by summing the probability for each of the paths that terminate in \(U\). This is \(\frac{1}{26} + \frac{25}{676}\),

    -\[\mathbb{P}(Q \mid \cdot U) = \frac{\frac{1}{26}}{\frac{1}{26} + \frac{25}{676}} = \frac{26}{51}\]
    +\[\mathbb{P}(Q \mid \cdot U) = \frac{\frac{1}{26}}{\frac{1}{26} + \frac{25}{676}} = \frac{26}{51}.\] +
    +

    Exercises#

    +
    + +

    Exercise 32

    +
    +

    A box contains two tickets, labeled \(H\) or \(T\). There is a 25% chance the box contains two \(H\)s. There is a 25% chance the box contains two \(T\)s. There is a 50% chance the box contains one \(H\) and one \(T\).

    +
      +
    1. What is the chance of drawing an \(H\)?

    2. +
    3. Suppose you draw an \(H\). What is the chance that the box contained two \(T\)s?

    4. +
    5. Suppose you draw an \(H\). What is the chance that the box contained two \(H\)s?

    6. +
    7. After replacing the \(H\), what is the chance of selecting another \(H\)?

    8. +
    +
    +
    +
    + +

    Exercise 33

    +
    +

    Consider a rare disease that affects 1 in 10,000 people in a population. A medical test for the disease has a 99% chance of correctly identifying a diseased person (true positive) and a 99% chance of correctly identifying a non-diseased person (true negative).

    +

    If a person from this population tests positive for the disease, what is the probability that they actually have the disease?

    +

    Given:

    +
    +\[\mathbb{P}(\text{Disease}) = \frac{1}{10,000}\]
    +
    +\[\mathbb{P}(\text{No disease}) = 1 - \mathbb{P}(D)\]
    +
    +\[\mathbb{P}(\text{Positive} | \text{Disease}) = 0.99\]
    +
    +\[\mathbb{P}(\text{Negative} | \text{No Disease}) = 0.99\]
    +
    +
    +
    + +

    Exercise 34

    +
    +

    You’re playing basketball at the park when your team picks up an unknown player. The unknown player is equally likely to be a scrub or a baller. A baller makes 90% of their shots and each shot is independent. A scrub makes 10% of their shots and each shot is independent.

    +
      +
    1. What is the chance an unknown makes their first shot?

    2. +
    3. What is the chance that the player makes their second shot if they made their first?

    4. +
    5. Are the first and second shot outcomes independent from your perspective?

    6. +
    +
    +
    +
    + +

    Exercise 35

    +
    +

    A pilgrim, traveling home, is wandering through a strange land when a troll appears:

    +
    +

    Woe, to pass, pilgrim choose of these doors two.
    Which is which, I cannot reveal to you.
    Home with chance 7 or 73.
    It depends on your choice and fate’s decree.
    Independent but certainty you lack.
    Take now two draws before I turn thee back.

    +
    +
      +
    1. What is the probability the pilgrim opens a door that leads home on the first draw?

    2. +
    3. The troll, old in his years, has seen 200 million other pilgrims pass through. Each has chosen a door randomly to start and then the other door second if the first didn’t take them home. Finish filling in the table below with the expected counts.

    4. +
    + + + + + + + + + + + + + + + + + + + + +

    Door 7 second

    Door 73 second

    Home after first

    Door 7 first

    0 million

    Door 73 first

    0 million

    73 million

    +
      +
    1. If the first draw does not lead home, what is the probability the pilgrim opened the door that leads home with chance 7%? What is the probability the pilgrim opened the door that leads home with chance 73%?

    2. +
    3. If the first draw does not lead home, should the pilgrim open a different door on the next draw or try the same door again? Or does it not matter?

    4. +
    5. What is the probability that the pilgrim remains in exile?

    6. +
    7. The pilgrim, alarmed by the risk of remaining in exile, bargains with the troll to replace the two doors with one 40% chance door. This averages the chances. Is this wise?

    8. +
    +
    +
    +
    + +

    Exercise 36

    +
    +

    Suppose that a product is sold on Amazon and it has either high quality (\(H\)) or low quality (\(L\)). We observe a single product review, which can either be good or bad. Reviewers can be of two types: fake or truth-teller. A fake reviewer always leaves a positive review, regardless of the product quality. A truth-teller reviewer leaves a positive review when the product is high quality and leaves a negative review if the product is low quality.

    +

    Assume \(\mathbb{P}(H) = \frac{1}{2}\) and that each type of reviewer is equally likely.

    +
      +
    • a.) What is \(\mathbb{P}(\text{good review})\)?

    • +
    • b.) What is \(\mathbb{P}(\text{good review} \mid H)\)?

    • +
    • c.) What is \(\mathbb{P}(H \mid \text{good review})\)?

    • +
    • d.) Draw a probability tree that summarizes the probabilities based on product quality, review type, and reviewer type.

    • +
    • e.) Are the events of “high quality product” and “good review” independent or dependent? Explain.

    • +
    • f.) Suppose the truth-teller is replaced by a joker who leaves a negative review if the product is high quality and a positive review if the product is low quality. What is \(\mathbb{P}(H \mid \text{bad review})\)?

    • +
    +
    +
    +