MapLines.tools.priors

Prior and likelihood functions used in the spectral fitting process.

MapLines.tools.priors

Likelihood and prior functions used by MapLines spectral models.

This module defines the statistical functions required for Bayesian inference in MapLines. In particular, it provides routines to evaluate:

  • the log-likelihood of a spectral model given an observed spectrum

  • the log-prior for the model parameters

  • the log-posterior probability used by the MCMC sampler

These functions are used together with the spectral models defined in MapLines.tools.models and the MCMC driver implemented in MapLines.tools.mcmc.

Notes

The likelihood assumes Gaussian uncertainties in the observed spectrum, while the prior enforces physically and empirically motivated parameter ranges defined in the configuration files.

MapLines.tools.priors.lnlike_gauss_Lin(theta, spec, specE, x, waves0, fac0, facN0, velfac0, velfacN0, fwhfac0, fwhfacN0, names0, n_lines, vals, skew, voigt, lorentz, outflow, powlaw, feii, data)[source]

Compute the log-likelihood of a spectral line model.

The likelihood is calculated assuming Gaussian uncertainties in the observed spectrum.

Parameters:
  • theta (array_like) – Model parameters.

  • spec (ndarray) – Observed spectrum.

  • specE (ndarray) – Uncertainty of the spectrum.

  • x (ndarray) – Spectral axis.

  • waves0 (array_like) – Rest wavelengths of spectral lines.

  • fac0 (array_like) – Flux normalization parameters.

  • facN0 (array_like) – Flux normalization parameters.

  • velfac0 (array_like) – Velocity scaling factors.

  • velfacN0 (array_like) – Velocity scaling factors.

  • fwhfac0 (array_like) – Line width scaling factors.

  • fwhfacN0 (array_like) – Line width scaling factors.

  • names0 (list) – Names of spectral components.

  • n_lines (int) – Number of emission lines.

  • vals (dict) – Additional configuration parameters.

Returns:

Log-likelihood value.

Return type:

float

MapLines.tools.priors.lnprior_gauss_Lin(theta, Infvalues, Supvalues, valsp, skew=False, outflow=False, powlaw=False, feii=False)[source]

Evaluate the prior probability for model parameters.

The prior enforces parameter boundaries and additional physical constraints depending on the selected model components.

Parameters:
  • theta (array_like) – Model parameters.

  • Infvalues (array_like) – Lower bounds of parameters.

  • Supvalues (array_like) – Upper bounds of parameters.

  • valsp (dict) – Dictionary containing prior limits for special components.

  • skew (bool) – Flags enabling additional model components.

  • outflow (bool) – Flags enabling additional model components.

  • powlaw (bool) – Flags enabling additional model components.

  • feii (bool) – Flags enabling additional model components.

Returns:

Log-prior value (0 or -inf).

Return type:

float

MapLines.tools.priors.lnprob_gauss_Lin(theta, spec, specE, x, Infvalues, Supvalues, valsp, waves0, fac0, facN0, velfac0, velfacN0, fwhfac0, fwhfacN0, names0, n_lines, vals, skew, voigt, lorentz, outflow, powlaw, feii, data)[source]

Compute the posterior probability of the spectral model.

The posterior is defined as the sum of the prior and the likelihood.

Parameters:

theta (array_like) – Model parameters.

Returns:

Log-posterior probability.

Return type:

float