jesterTOV.inference.samplers.eos_reweighting.resample_eos_posterior#
- resample_eos_posterior(
- masses,
- lambdas,
- radii,
- posterior_weights,
- n_samples=None,
- seed=0,
Resample a tabulated EOS set into equal-weight posterior samples.
This is a small, standalone utility that turns the discrete weighted posterior produced by
EOSReweightingSampler.sample()(one weight per input EOS curve) into an equal-weight set of posterior draws, by drawing curves with replacement according toposterior_weights. It only needs the gridded curves and weights, so it works equally well on a fresh set of EOS curves that were reweighted outside ofEOSReweightingSampler(e.g. with a custom likelihood), as long asmasses/lambdas/radiishare a common mass grid — seeEOSReweightingSampler.load_and_grid()for a helper that builds such a grid from a list of NPZ files.- Parameters:
masses (
Float[Array, 'N L']|Float[ndarray, 'N L']) – Common-grid EOS curves of shape[N, L], e.g. as returned byEOSReweightingSampler.load_and_grid().lambdas (
Float[Array, 'N L']|Float[ndarray, 'N L']) – Common-grid EOS curves of shape[N, L], e.g. as returned byEOSReweightingSampler.load_and_grid().radii (
Float[Array, 'N L']|Float[ndarray, 'N L']) – Common-grid EOS curves of shape[N, L], e.g. as returned byEOSReweightingSampler.load_and_grid().posterior_weights (
Float[Array, 'N']|Float[ndarray, 'N']) – Normalised posterior weight per EOS (sums to 1), e.g.sample_output.metadata["evidence"]["posterior_weights"].n_samples (
int|None) – Number of samples to draw.None(default) uses the Kish effective sample size \(N_\mathrm{eff} = 1/\sum_a (w^{(a)})^2\), rounded to the nearest integer.seed (
int) – Seed for the NumPy random generator used to draw the resample.
- Return type:
- Returns:
dict –
eos_index: index into the input arrays for each draw, shape[n_samples]masses_EOS,Lambdas_EOS,radii_EOS: resampled curves, shape[n_samples, L]