Spaces:
Running
Running
enhance clarity of explanations regarding expectations & their significance in probability distr.
Browse files
probability/11_expectation.py
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
|
11 |
import marimo
|
12 |
|
13 |
-
__generated_with = "0.
|
14 |
app = marimo.App(width="medium", app_title="Expectation")
|
15 |
|
16 |
|
@@ -22,9 +22,9 @@ def _(mo):
|
|
22 |
|
23 |
_This notebook is a computational companion to ["Probability for Computer Scientists"](https://chrispiech.github.io/probabilityForComputerScientists/en/part2/expectation/), by Stanford professor Chris Piech._
|
24 |
|
25 |
-
|
26 |
|
27 |
-
|
28 |
"""
|
29 |
)
|
30 |
return
|
@@ -36,11 +36,11 @@ def _(mo):
|
|
36 |
r"""
|
37 |
## Definition of Expectation
|
38 |
|
39 |
-
|
40 |
|
41 |
$$E[X] = \sum_x x \cdot P(X=x)$$
|
42 |
|
43 |
-
|
44 |
"""
|
45 |
)
|
46 |
return
|
|
|
10 |
|
11 |
import marimo
|
12 |
|
13 |
+
__generated_with = "0.12.6"
|
14 |
app = marimo.App(width="medium", app_title="Expectation")
|
15 |
|
16 |
|
|
|
22 |
|
23 |
_This notebook is a computational companion to ["Probability for Computer Scientists"](https://chrispiech.github.io/probabilityForComputerScientists/en/part2/expectation/), by Stanford professor Chris Piech._
|
24 |
|
25 |
+
Expectations are fascinating — they represent the "center of mass" of a probability distribution. while they're often called "expected values" or "averages," they don't always match our intuition about what's "expected" to happen.
|
26 |
|
27 |
+
For me, the most interesting part about expectations is how they quantify what happens "on average" in the long run, even if that average isn't a possible outcome (like expecting 3.5 on a standard die roll).
|
28 |
"""
|
29 |
)
|
30 |
return
|
|
|
36 |
r"""
|
37 |
## Definition of Expectation
|
38 |
|
39 |
+
Expectation (written as $E[X]$) is basically the "average outcome" of a random variable, but with a twist - we weight each possible value by how likely it is to occur. I like to think of it as the "center of gravity" for probability.
|
40 |
|
41 |
$$E[X] = \sum_x x \cdot P(X=x)$$
|
42 |
|
43 |
+
People call this concept by different names - mean, weighted average, center of mass, or 1st moment if you're being fancy. They're all calculated the same way, though: multiply each value by its probability, then add everything up.
|
44 |
"""
|
45 |
)
|
46 |
return
|