Figure 9.12:

Values of \chi ^2 and F versus the number of data points when estimating 2 and 5 parameters.

Figure 9.12

Code for Figure 9.12

Text of the GNU GPL.

main.py


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Converted from chiF.m - compare chi-squared and F distributions
import numpy as np
from scipy.stats import chi2, f as f_dist
from misc import save_ascii

p     = np.array([2, 5])
alpha = 0.95
nplot = 100
large = 50

table = None
for i, pi in enumerate(p):
    ndata  = np.linspace(pi+1, large, nplot)
    chisq  = chi2.ppf(alpha, pi) * np.ones(nplot)
    Fstat  = pi * f_dist.ppf(alpha, pi, ndata - pi)
    block  = np.column_stack([ndata, Fstat, chisq])
    table  = block if table is None else np.column_stack([table, block])

save_ascii('chiF.dat', table)