Luminosity function likelihood (lumfunc_likelihood
)¶
Fit tracer luminosity functions and produce model constraints.
Data processing¶
Raise an exception when the data source is not available or not in the correct format. |
|
Raise an exception when the data source does not appear to be self-consistent. |
|
|
Luminosity function measurements for a tracer sample. |
Likelihood evaluation¶
|
Luminosity function likelihood. |
- exception horizonground.lumfunc_likelihood.DataSourceError[source]¶
Bases:
OSError
Raise an exception when the data source is not available or not in the correct format.
- exception horizonground.lumfunc_likelihood.DataSourceWarning[source]¶
Bases:
UserWarning
Raise an exception when the data source does not appear to be self-consistent.
- class horizonground.lumfunc_likelihood.LumFuncMeasurements(measurement_file, uncertainty_file=None, base10_log=True)[source]¶
Bases:
object
Luminosity function measurements for a tracer sample.
- Parameters
measurement_file (str or
pathlib.Path
) – File path to luminosity function measurements.uncertainty_file (str or
pathlib.Path
or None, optional) – File path to luminosity function uncertainties.base10_log (bool, optional) – If True (default), measurement values are converted to base-10 logarithms. String
'lg_'
is detected in file headers to determine whether loaded measurements are already in base-10 logarithms.
- Variables
luminosity_bins (list of float) – Luminosity bin centres.
redshift_bins (list of float) – Redshift bin centres.
redshift_labels (list of str) – Redshift bin labels.
Notes
Data files are assumed to be an array where rows correspond to increasing luminosity bins and columns correspond to increasing redshift bins. The first line should be a comment line for column headings and the first column should be the luminosity bins. Redshift bin labels are read from column headings as suffices in the format e.g. “z_0.5_1.5”. If symmetric uncertainties are given for base-10 logarithmic luminosity function and conversion to linear values is needed, the larger asymmetric uncertainty on the linear luminosity function value is taken.
- __getitem__(z_key)[source]¶
Get luminosity function measurements and uncertainties (if available) for a specific redshift bin.
- Parameters
z_key (int, slice or str) – Slice or integer index or string representing redshift bins. If a string, the accepted format is e.g.
z=1.0
.- Returns
Measurements and uncertainties for the redshift bin(s).
- Return type
numpy.ndarray
,numpy.ndarray
or None
- get_statistics()[source]¶
Return the empirical luminosity function data measurements and uncertainties as mean and variance statistics.
- Returns
data_mean (
numpy.ndarray
) – Luminosity function measurements as empirical mean.data_variance (
numpy.ndarray
or None) – Luminosity function uncertainties as empirical variance, if available.
Notes
Data vectors are ordered by increasing redshift bins and within the same redshift bin ordered by increasing luminosity.
- class horizonground.lumfunc_likelihood.LumFuncLikelihood(model_lumfunc, measurement_file, prior_file, uncertainty_file=None, fixed_file=None, prescription='poisson', model_constraint=None, model_options=None, covariance_matrix=None)[source]¶
Bases:
LumFuncMeasurements
Luminosity function likelihood.
Notes
The built-in likelihood distribution is a multivariate normal approximation near the maximum point of the Poisson distribution that describes the tracer number count in redshift and luminosity bins, with different prescriptions of the luminosity function uncertainties to the diagonal covariance matrix of the multivariate normal distribution (see appendix B of 1). The built-in prior distribution is multivariate uniform.
- 1
Pozzetti L. et al., 2016. A&A 590, A3. [arXiv: 1603.01453]
- Parameters
model_lumfunc (callable) – Luminosity function model. Must return base-10 logarithmic values or accept base10_log boolean keyword argument.
measurement_file (str or
pathlib.Path
) – Luminosity function measurement file path.prior_file (str or
pathlib.Path
) – Luminosity function model prior file path. The prior parameter values (parameter ranges) may not matter, but the parameter names provided in the file do.model_constraint (callable or None, optional) – Additional model constraint(s) to be imposed on model parameters as a prior (default is None).
uncertainty_file (str or
pathlib.Path
or None, optional) – Luminosity function uncertainty file path (default is None). Ignored if data_covariance is provided.fixed_file (str or
pathlib.Path
or None, optional) – Luminosity function model fixed parameter file path (default is None). This covers any model parameter(s) not included in the prior.prescription ({‘native’, ‘poisson’, ‘symlg’, ‘symlin’}, str, optional) – Gaussian likelihood approximation prescription (default is ‘poisson’).
model_options (dict or None, optional) – Additional parameters passed to the model_lumfunc for model evaluation (default is None). This should not contain parametric luminosity function model parameters but only Python function implementation optional parameters (e.g.
redshift_pivot=2.2
forquasar_PLE_lumfunc()
).covariance_matrix (float array_like or None, optional) – Covariance matrix for the multivariate normal likelihood approximation (default is None). Its dimensions must match the length of the data vector flattened by redshift and luminosity bins.
- Variables
data_points (list of float) – A vector of (luminosity, redshift) points for each valid luminosity function measurement.
data_vector (float
numpy.ndarray
) – Flattened luminosity function measurements for valid data points.fixed (prior,) – Ordered dictionary of varied prior parameter names and values or fixed parameter names and values. The parameters are ordered as in the input files, so that the ordering of luminosity function arguments is consistent.
- __call__(param_point, use_prior=False)[source]¶
Evaluate the logarithmic likelihood at the model parameter point.
- Parameters
param_point (float array_like) –
model_lumfunc
parametric model parameters ordered in the same way as the prior parameters.use_prior (bool, optional) – If True (default is False), use the user-input prior range.
- Returns
Logarithmic likelihood value.
- Return type