You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a65c025
Browse filesBrowse the repository at this point in the historyBrowse files
authored
[multi_hyper] Conversion to JAX and stylesheet check (#657)
* conversion to jax and stylesheet check
* minor updates
---------
Co-authored-by: John Stachurski <[email protected]>
Co-authored-by: HumphreyYang <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Now let's compute the mean and variance-covariance matrix of $X$ when $n=6$.
335
329
336
-
```{code-cell}python3
330
+
```{code-cell}ipython3
337
331
n = 6 # number of draws
338
332
μ, Σ = urn.moments(n)
339
333
```
340
334
341
-
```{code-cell}python3
335
+
```{code-cell}ipython3
342
336
# mean
343
337
μ
344
338
```
345
339
346
-
```{code-cell}python3
340
+
```{code-cell}ipython3
347
341
# variance-covariance matrix
348
342
Σ
349
343
```
350
344
351
345
We can simulate a large sample and verify that sample means and covariances closely approximate the population means and covariances.
352
346
353
-
```{code-cell}python3
347
+
```{code-cell}ipython3
354
348
size = 10_000_000
355
349
sample = urn.simulate(n, size=size)
356
350
```
357
351
358
-
```{code-cell}python3
352
+
```{code-cell}ipython3
359
353
# mean
360
354
np.mean(sample, 0)
361
355
```
362
356
363
-
```{code-cell}python3
357
+
```{code-cell}ipython3
364
358
# variance covariance matrix
365
359
np.cov(sample.T)
366
360
```
367
361
368
362
Evidently, the sample means and covariances approximate their population counterparts well.
369
363
370
-
### Quality of Normal Approximation
364
+
### Quality of normal approximation
371
365
372
366
To judge the quality of a multivariate normal approximation to the multivariate hypergeometric distribution, we draw a large sample from a multivariate normal distribution with the mean vector and covariance matrix for the corresponding multivariate hypergeometric distribution and compare the simulated distribution with the population multivariate hypergeometric distribution.
0 commit comments