Spaces:
Running
Running
fixes: width = `medium` & line spacing
Browse files
probability/03_probability_of_or.py
CHANGED
|
@@ -10,7 +10,7 @@
|
|
| 10 |
import marimo
|
| 11 |
|
| 12 |
__generated_with = "0.11.2"
|
| 13 |
-
app = marimo.App()
|
| 14 |
|
| 15 |
|
| 16 |
@app.cell
|
|
@@ -141,6 +141,7 @@ def _(mo):
|
|
| 141 |
Why subtract $P(E \cap F)$? Because when we add $P(E)$ and $P(F)$, we count the overlap twice!
|
| 142 |
|
| 143 |
For example, consider calculating $P(\text{prime or even})$ when rolling a die:
|
|
|
|
| 144 |
- Prime numbers: {2, 3, 5}
|
| 145 |
- Even numbers: {2, 4, 6}
|
| 146 |
- The number 2 is counted twice unless we subtract its probability
|
|
@@ -235,7 +236,9 @@ def _(event_type, mo, plt, venn2):
|
|
| 235 |
### Mutually Exclusive Events
|
| 236 |
|
| 237 |
$P(\text{Odd}) = \frac{3}{6} = 0.5$
|
|
|
|
| 238 |
$P(\text{Even}) = \frac{3}{6} = 0.5$
|
|
|
|
| 239 |
$P(\text{Odd} \cap \text{Even}) = 0$
|
| 240 |
|
| 241 |
$P(\text{Odd} \cup \text{Even}) = P(\text{Odd}) + P(\text{Even}) = 1$
|
|
@@ -251,7 +254,9 @@ def _(event_type, mo, plt, venn2):
|
|
| 251 |
### Non-Mutually Exclusive Events
|
| 252 |
|
| 253 |
$P(\text{Prime}) = \frac{3}{6} = 0.5$ (2,3,5)
|
|
|
|
| 254 |
$P(\text{Even}) = \frac{3}{6} = 0.5$ (2,4,6)
|
|
|
|
| 255 |
$P(\text{Prime} \cap \text{Even}) = \frac{1}{6}$ (2)
|
| 256 |
|
| 257 |
$P(\text{Prime} \cup \text{Even}) = \frac{3}{6} + \frac{3}{6} - \frac{1}{6} = \frac{5}{6}$
|
|
@@ -267,7 +272,9 @@ def _(event_type, mo, plt, venn2):
|
|
| 267 |
### Complex Event Interaction
|
| 268 |
|
| 269 |
$P(x < 3) = \frac{2}{6}$ (1,2)
|
|
|
|
| 270 |
$P(\text{Even}) = \frac{3}{6}$ (2,4,6)
|
|
|
|
| 271 |
$P(x < 3 \cap \text{Even}) = \frac{1}{6}$ (2)
|
| 272 |
|
| 273 |
$P(x < 3 \cup \text{Even}) = \frac{2}{6} + \frac{3}{6} - \frac{1}{6} = \frac{4}{6}$
|
|
|
|
| 10 |
import marimo
|
| 11 |
|
| 12 |
__generated_with = "0.11.2"
|
| 13 |
+
app = marimo.App(width="medium")
|
| 14 |
|
| 15 |
|
| 16 |
@app.cell
|
|
|
|
| 141 |
Why subtract $P(E \cap F)$? Because when we add $P(E)$ and $P(F)$, we count the overlap twice!
|
| 142 |
|
| 143 |
For example, consider calculating $P(\text{prime or even})$ when rolling a die:
|
| 144 |
+
|
| 145 |
- Prime numbers: {2, 3, 5}
|
| 146 |
- Even numbers: {2, 4, 6}
|
| 147 |
- The number 2 is counted twice unless we subtract its probability
|
|
|
|
| 236 |
### Mutually Exclusive Events
|
| 237 |
|
| 238 |
$P(\text{Odd}) = \frac{3}{6} = 0.5$
|
| 239 |
+
|
| 240 |
$P(\text{Even}) = \frac{3}{6} = 0.5$
|
| 241 |
+
|
| 242 |
$P(\text{Odd} \cap \text{Even}) = 0$
|
| 243 |
|
| 244 |
$P(\text{Odd} \cup \text{Even}) = P(\text{Odd}) + P(\text{Even}) = 1$
|
|
|
|
| 254 |
### Non-Mutually Exclusive Events
|
| 255 |
|
| 256 |
$P(\text{Prime}) = \frac{3}{6} = 0.5$ (2,3,5)
|
| 257 |
+
|
| 258 |
$P(\text{Even}) = \frac{3}{6} = 0.5$ (2,4,6)
|
| 259 |
+
|
| 260 |
$P(\text{Prime} \cap \text{Even}) = \frac{1}{6}$ (2)
|
| 261 |
|
| 262 |
$P(\text{Prime} \cup \text{Even}) = \frac{3}{6} + \frac{3}{6} - \frac{1}{6} = \frac{5}{6}$
|
|
|
|
| 272 |
### Complex Event Interaction
|
| 273 |
|
| 274 |
$P(x < 3) = \frac{2}{6}$ (1,2)
|
| 275 |
+
|
| 276 |
$P(\text{Even}) = \frac{3}{6}$ (2,4,6)
|
| 277 |
+
|
| 278 |
$P(x < 3 \cap \text{Even}) = \frac{1}{6}$ (2)
|
| 279 |
|
| 280 |
$P(x < 3 \cup \text{Even}) = \frac{2}{6} + \frac{3}{6} - \frac{1}{6} = \frac{4}{6}$
|