sp_validation.statistics¶
STATISTICS.
- Name:
statistics.py
- Description:
Cosmology-independent statistical helpers (jackknife resampling, chi2/PTE, covariance<->correlation, OneCovariance reshaping). Extracted verbatim from the former basic.py.
- jackknif_weighted_average2(data, weights, remove_size=0.1, n_realization=100)[source]¶
Add docstring.
…
- corr_from_cov(cov)[source]¶
Correlation matrix from a covariance matrix.
- Parameters:
cov (numpy.ndarray) – Covariance matrix.
- Returns:
Correlation matrix.
- Return type:
- chi2_and_pte(data_vector, cov, verbose=False)[source]¶
Chi-squared, reduced chi-squared and PTE for a data vector.
The data vector is assumed to be zero-mean under the null hypothesis, so
chi2 = d^T C^-1 d.- Parameters:
data_vector (numpy.ndarray) – Data vector.
cov (numpy.ndarray) – Covariance matrix of the data vector.
verbose (bool, optional) – If
True, print the statistics; default isFalse.
- Returns:
(chi2, reduced_chi2, pte).- Return type:
- cov_from_one_covariance(cov_one_cov, gaussian=True)[source]¶
Reshape a OneCovariance
covariance_listtable into a matrix.- Parameters:
cov_one_cov (numpy.ndarray) – Flat OneCovariance output (e.g. from
covariance_list_..._Cell.dat), with one row per(i, j)element pair.gaussian (bool, optional) – If
Trueuse the Gaussian-only column, otherwise the Gaussian+non-Gaussian column; default isTrue.
- Returns:
Square covariance matrix.
- Return type: