@@ -160,7 +160,8 @@ Check that your answers agree with `u.mean()` and `u.var()`.
160
160
Another useful distribution is the Bernoulli distribution on $S = \{ 0,1\} $, which has PMF:
161
161
162
162
$$
163
- p(i) = \theta^{i-1} (1 - \theta)^i
163
+ p(i) = \theta^i (1 - \theta)^{1-i}
164
+ \qquad (i = 0, 1)
164
165
$$
165
166
166
167
Here $\theta \in [ 0,1] $ is a parameter.
@@ -171,7 +172,7 @@ We can think of this distribution as modeling probabilities for a random trial w
171
172
* $p(0) = 1 - \theta$ means that the trial fails (takes value 0) with
172
173
probability $1-\theta$
173
174
174
- The formula for the mean is $p $, and the formula for the variance is $p (1-p )$.
175
+ The formula for the mean is $\theta $, and the formula for the variance is $\theta (1-\theta )$.
175
176
176
177
We can import the Bernoulli distribution on $S = \{ 0,1\} $ from SciPy like so:
177
178
@@ -186,11 +187,10 @@ Here's the mean and variance at $\theta=0.4$
186
187
u.mean(), u.var()
187
188
```
188
189
189
- Now let's evaluate the PMF
190
+ We can evaluate the PMF as follows
190
191
191
192
``` {code-cell} ipython3
192
- u.pmf(0)
193
- u.pmf(1)
193
+ u.pmf(0), u.pmf(1)
194
194
```
195
195
196
196
#### Binomial distribution
@@ -756,7 +756,11 @@ x.mean(), x.var()
756
756
``` {exercise}
757
757
:label: prob_ex4
758
758
759
- Check that the formulas given above produce the same numbers.
759
+ If you try to check that the formulas given above for the sample mean and sample
760
+ variance produce the same numbers, you will see that the variance isn't quite
761
+ right. This is because SciPy uses $1/(n-1)$ instead of $1/n$ as the term at the
762
+ front of the variance. (Some books define the sample variance this way.)
763
+ Confirm.
760
764
```
761
765
762
766
0 commit comments