We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d628773 commit 69b46e0Copy full SHA for 69b46e0
1 file changed
lectures/stats_examples.md
@@ -172,13 +172,13 @@ We verify the above and compute the mean and variance using `numpy`.
172
173
```{code-cell} ipython3
174
Benford_pmf = np.array([np.log10(1+1/d) for d in range(1,10)])
175
-k = np.array(range(1,10))
+k = np.arange(1, 10)
176
177
# mean
178
-mean = np.sum(Benford_pmf * k)
+mean = k @ Benford_pmf
179
180
# variance
181
-var = np.sum([(k-mean)**2 * Benford_pmf])
+var = ((k - mean) ** 2) @ Benford_pmf
182
183
# verify sum to 1
184
print(np.sum(Benford_pmf))
0 commit comments