h0rton.h0_inference.h0_utils
¶
Module Contents¶
Classes¶
CosmoConverter |
Convert the time-delay distance to H0 and vice versa |
Functions¶
gaussian_ll_pdf (x, mu, sigma) |
Evaluates the (unnormalized) log of the normal PDF at point x |
reorder_to_tdlmc (img_array, increasing_dec_i, abcd_ordering_i) |
Apply the permutation scheme for reordering the list of ra, dec, and time delays to conform to the order in the TDLMC challenge |
pred_to_natural_gaussian (pred_mu, pred_cov_mat, shift, scale) |
Convert the BNN-predicted multivariate Gaussian parameters into the natural space counterparts by reverse transformation |
get_lognormal_stats (all_samples) |
Compute lognormal stats robustly, using median stats, assuming the samples are drawn from a lognormal distribution |
get_lognormal_stats_naive (all_samples, all_weights=None) |
Compute lognormal stats assuming the samples are drawn from a lognormal distribution |
get_normal_stats (all_samples) |
|
get_normal_stats_naive (all_samples, all_weights) |
|
remove_outliers_from_lognormal (data, level=3) |
Remove extreme outliers corresponding to level-STD away from the mean |
combine_lenses (likelihood_type, z_lens, z_src, true_Om0, samples_save_path=None, corner_save_path=None, n_run=100, n_burn=400, n_walkers=10, **posterior_parameters) |
Combine lenses in the D_dt space |
-
h0rton.h0_inference.h0_utils.
gaussian_ll_pdf
(x, mu, sigma)[source]¶ Evaluates the (unnormalized) log of the normal PDF at point x
- x : float or array-like
- point at which to evaluate the log pdf
- mu : float or array-like
- mean of the normal on a linear scale
- sigma : float or array-like
- standard deviation of the normal on a linear scale
-
h0rton.h0_inference.h0_utils.
reorder_to_tdlmc
(img_array, increasing_dec_i, abcd_ordering_i)[source]¶ Apply the permutation scheme for reordering the list of ra, dec, and time delays to conform to the order in the TDLMC challenge
- img_array : array-like
- array of properties corresponding to the AGN images
- array-like
- img_array reordered to the TDLMC order
-
h0rton.h0_inference.h0_utils.
pred_to_natural_gaussian
(pred_mu, pred_cov_mat, shift, scale)[source]¶ Convert the BNN-predicted multivariate Gaussian parameters into the natural space counterparts by reverse transformation
pred_mu : np.array of shape [Y_dim,] pred_cov_mat : np.array of shape [Y_dim, Y_dim] scale : np.array of shape [Y_dim,]
vector by which the features were scaled, e.g. the training-set feature standard deviations- shift : np.array of shape [Y_dim,]
- vector by which the features were shifted, e.g. the training-set feature means
Derive it or go here: https://math.stackexchange.com/questions/332441/affine-transformation-applied-to-a-multivariate-gaussian-random-variable-what
- mu : np.array of shape [Y_dim,]
- mu in natural space
- cov_mat : np.array of shape [Y_dim, Y_dim]
- covariance matrix in natural space
-
class
h0rton.h0_inference.h0_utils.
CosmoConverter
(z_lens, z_src, H0=70.0, Om0=0.3)[source]¶ Convert the time-delay distance to H0 and vice versa
This was modified from lenstronomy.Cosmo.cosmo_solver to handle array types.
-
h0rton.h0_inference.h0_utils.
get_lognormal_stats
(all_samples)[source]¶ Compute lognormal stats robustly, using median stats, assuming the samples are drawn from a lognormal distribution
-
h0rton.h0_inference.h0_utils.
get_lognormal_stats_naive
(all_samples, all_weights=None)[source]¶ Compute lognormal stats assuming the samples are drawn from a lognormal distribution
-
h0rton.h0_inference.h0_utils.
remove_outliers_from_lognormal
(data, level=3)[source]¶ Remove extreme outliers corresponding to level-STD away from the mean
- data : np.array
- data expected to follow a lognormal distribution
-
h0rton.h0_inference.h0_utils.
combine_lenses
(likelihood_type, z_lens, z_src, true_Om0, samples_save_path=None, corner_save_path=None, n_run=100, n_burn=400, n_walkers=10, **posterior_parameters)[source]¶ Combine lenses in the D_dt space
- true_Om0 : float
- true Om0, not inferred
- likelihood_type : str
- ‘DdtGaussian’, ‘DdtLogNorm’, ‘DdtHistKDE’ supported. ‘DdtGaussian’ must have ‘ddt_mean’, ‘ddt_sigma’. ‘DdtLogNorm’ must have ‘ddt_mu’ and ‘ddt_sigma’. ‘DdtHistKDE’ must have ‘lens_ids’ and ‘samples_dir’.