Bootstrap Lookups#

The LaplaceBootstrapTest allows a previously computed bootstrap experiment to be restored as a lookup table. That is, we can compute the distribution of \(p(T =t | H_0)\) once and reuse it. This is possible because of the pivoting property of the test (see Bonse et al. subm).

In this tutorial we run several bootstrap experiments for different separations from the star and save the results.

Imports#

[1]:
from tqdm import tqdm
import numpy as np

from applefy.utils.positions import get_number_of_apertures
from applefy.statistics.bootstrapping import LaplaceBootstrapTest

Determine the number of noise observations#

The distribution of \(p(T =t | H_0)\) depends on the number of available noise values \(n\). We pre-compute the bootstrap experiments for the innermost 20 \(\lambda /D\). Further out the noise is most likely Gaussian and a t-test should be used.

[2]:
# -1 for the planet signal
max_n = get_number_of_apertures(20, 0.5)
min_n = get_number_of_apertures(1, 0.5) - 1
[3]:
min_n
[3]:
5
[4]:
max_n
[4]:
125

Run the bootstrap experiments#

Create the LaplaceBootstrapTest

[5]:
bs_laplace_model = LaplaceBootstrapTest(num_cpus=100)

Calculate the bootstrap experiments.

[7]:
# Loop over all separations of interest
for tmp_num_noise_values in tqdm(range(min_n, max_n)[::-1]):
    # 3.) Run the bootstrapping
    bs_laplace_model.run_bootstrap_experiment(
        memory_size=1e6,
        num_noise_values=tmp_num_noise_values,
        num_draws=1e9,
        approximation_interval=np.linspace(-7, 7, 10000))

Save the lookup table#

[ ]:
bs_laplace_model.save_lookups("path/to/save.csv")