Skip to content

Commit

Permalink
misc (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstac authored Aug 1, 2024
1 parent a58c4af commit 1a46d9d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lectures/prob_dist.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ Check that your answers agree with `u.mean()` and `u.var()`.
Another useful distribution is the Bernoulli distribution on $S = \{0,1\}$, which has PMF:

$$
p(i) = \theta^{i-1} (1 - \theta)^i
p(i) = \theta^i (1 - \theta)^{1-i}
\qquad (i = 0, 1)
$$

Here $\theta \in [0,1]$ is a parameter.
Expand All @@ -171,7 +172,7 @@ We can think of this distribution as modeling probabilities for a random trial w
* $p(0) = 1 - \theta$ means that the trial fails (takes value 0) with
probability $1-\theta$

The formula for the mean is $p$, and the formula for the variance is $p(1-p)$.
The formula for the mean is $\theta$, and the formula for the variance is $\theta(1-\theta)$.

We can import the Bernoulli distribution on $S = \{0,1\}$ from SciPy like so:

Expand All @@ -186,11 +187,10 @@ Here's the mean and variance at $\theta=0.4$
u.mean(), u.var()
```

Now let's evaluate the PMF
We can evaluate the PMF as follows

```{code-cell} ipython3
u.pmf(0)
u.pmf(1)
u.pmf(0), u.pmf(1)
```

#### Binomial distribution
Expand Down Expand Up @@ -756,7 +756,11 @@ x.mean(), x.var()
```{exercise}
:label: prob_ex4
Check that the formulas given above produce the same numbers.
If you try to check that the formulas given above for the sample mean and sample
variance produce the same numbers, you will see that the variance isn't quite
right. This is because SciPy uses $1/(n-1)$ instead of $1/n$ as the term at the
front of the variance. (Some books define the sample variance this way.)
Confirm.
```


Expand Down

1 comment on commit 1a46d9d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.