Skip to content

Commit

Permalink
bootstrap of PCA regularised multiclosure tests
Browse files Browse the repository at this point in the history
  • Loading branch information
comane committed Jun 11, 2024
1 parent 5557825 commit b0ec210
Showing 1 changed file with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from validphys.calcutils import calc_chi2
from validphys.results import ThPredictionsResult
from validphys.closuretest.closure_checks import check_multifit_replicas
from validphys.closuretest.multiclosure import bootstrapped_internal_multiclosure_dataset_loader

from reportengine import collect

Expand Down Expand Up @@ -153,6 +154,47 @@ def internal_multiclosure_dataset_loader_pca(
)


def bootstrapped_internal_multiclosure_dataset_loader_pca(
internal_multiclosure_dataset_loader,
n_fit_max,
n_fit,
n_rep_max,
n_rep,
n_boot_multiclosure,
rng_seed_mct_boot,
use_repeats=True,
explained_variance_ratio=0.99,
_internal_max_reps=None,
_internal_min_reps=20,
):
"""
Similar to multiclosure.bootstrapped_internal_multiclosure_dataset_loader but returns
PCA regularised covariance matrix, where the covariance matrix has been computed
from the replicas of the theory predictions.
"""

# get bootstrapped internal multiclosure dataset loader
bootstrap_imdl = bootstrapped_internal_multiclosure_dataset_loader(
internal_multiclosure_dataset_loader,
n_fit_max=n_fit_max,
n_fit=n_fit,
n_rep_max=n_rep_max,
n_rep=n_rep,
n_boot_multiclosure=n_boot_multiclosure,
rng_seed_mct_boot=rng_seed_mct_boot,
use_repeats=use_repeats,
)

# PCA regularise all the bootstrapped internal multiclosure dataset loaders
bootstrap_imdl_pca = [
internal_multiclosure_dataset_loader_pca(
imdl, explained_variance_ratio, _internal_max_reps, _internal_min_reps
)
for imdl in bootstrap_imdl
]
return tuple(bootstrap_imdl_pca)


def principal_components_bias_variance_dataset(internal_multiclosure_dataset_loader_pca):
"""
Compute the bias and variance for one datasets
Expand Down

0 comments on commit b0ec210

Please sign in to comment.