Calculates the marginal probability distribution for each model parameter. The distributions are weighted by the likelihood of each sample, making this useful for identifying the most probable parameter values from a set of Monte Carlo samples.
calculate_weighted_marginals(samples)
A named list where each element is a density object (a list with x
and y
components) corresponding to a model parameter.
Vector of parameter values
Vector of density estimates
A data frame containing parameter samples (e.g., log_N
, log_k0
)
and a negative log-likelihood column named NLL
.
This function uses the weighted_kde
helper to perform kernel density
estimation for each parameter, with weights derived from the normalized
likelihoods of the samples.