Bayesian Methods

Bayesian Methods

LUCI.LuciBayesian.log_likelihood_bayes(theta, axis_restricted, spectrum_restricted, yerr, model_type, line_num, sinc_width, vel_rel, sigma_rel)

Calculate a Gaussian likelihood function given a certain fitting function: gaussian, sinc, or sincgauss

Parameters:
  • theta – Fit parameters

  • axis_restricted – Wavelength axis restricted to fitting region

  • spectrum_restricted – Flux values corresponded to restricted wavelength axis

  • yerr – Noise in data

  • model_type – Fitting function (i.e. ‘gaussian’, ‘sinc’, or ‘sincgauss’)

  • line_num – Number of lines for fit

  • sinc_width – Fixed with of the sinc function

  • vel_rel

  • sigma_rel

Returns:

Gaussian log likelihood function evaluation

LUCI.LuciBayesian.log_prior(theta, axis_restricted, line_num, line, line_dict, mu_vel, mu_broad, sigma_vel, sigma_broad)

Calculate log prior assuming uniform priors on the amplitude and continuum values.

The uniform prior on the amplitude is 1/(A_max-A_min)

The uniform prior on the continuum is 1/(C_min-C_max)

The priors on the line position and Gaussian broadening are defined by Gaussian Priors The mu and std of these priors are calculated using a MDN (see LuciNetwork).

TODO: The velocity and broadening need to be updated to be in cm^-1 using the formulas in LuciDocs

Parameters:
  • theta – Fit parameters

  • axis_restricted

  • line_nun – Number of lines for fit

Returns:

If theta parameters are within the limits, we return the negative log prior value. Else we return -np.inf

LUCI.LuciBayesian.log_prior_uniform(theta, line_num, lines, line_dict)

Calculate log prior assuming uniform priors on the amplitude, line_position, broadening, and continuum values.

The uniform prior on the amplitude is 1/(A_max-A_min)

The uniform prior on the line position is 1/(x_max-x_min)

The uniform prior on the gaussian broadening is 1/(sigma_min-sigma_max)

The uniform prior on the continuum is 1/(C_min-C_max)

Parameters:
  • theta – Fit parameters

  • line_nun – Number of lines for fit

Returns:

If theta parameters are within the limits, we return the negative log prior value. Else we return -np.inf

LUCI.LuciBayesian.log_probability(theta, axis_restricted, spectrum_restricted, yerr, model_type, line_num, lines, line_dict, sinc_width, prior_gauss, vel_rel, sigma_rel, mdn)

Calculate a Gaussian likelihood function given a certain fitting function: gaussian, sinc, or sincgauss

Parameters:
  • theta – Fit parameters

  • axis_restricted – Wavelength axis restricted to fitting region

  • spectrum_restricted – Flux values corresponded to restricted wavelength axis

  • yerr – Noise in data

  • model_type – Fitting function (i.e. ‘gaussian’, ‘sinc’, or ‘sincgauss’)

  • line_num – Number of lines for fit

  • lines – List of lines to fit

  • line_dict – Dictionary of available lines with wavelength in nm

  • sinc_width – Fixed with of the sinc function

  • prior_gauss – Parameters for Gaussian priors [mu_vel, mu_broad, sigma_vel, sigma_broad]

  • vel_rel

  • sigma_rel

  • mdn – Boolean for MDN

Returns:

If not finite or if an nan we return -np.inf. Otherwise, we return the log likelihood + log prior