Generating training samples for the base model componenets
This short example shows how to use the Resampler class to conviently generate samples in the parameter space that cover the same region as a target set of simulations.
We start by importing all the relevant modules for this example.
[1]:
import numpy as np
from matryoshka.training_funcs import Resampler
from matryoshka.plot import sample_space
For this example we use the Aemulus simulations. The list of the simulation samples can be found in the repo https://github.com/zxzhai/emulator.
[2]:
simulation_samples = np.loadtxt("/Users/jamie/Desktop/AEMULUS/aemulus-emulator-master/cosmology_camb_full.dat")
We now initalise our re-sampler passing the locations of the Aemulus samples.
[3]:
laten_sampler = Resampler(simulation_samples=simulation_samples, use_latent_space=True)
new_samples_latent = laten_sampler.new_samples(1000)
We can plot our new samples with the convenience function matryoshka.plot.sample_space.
[4]:
set_labels = ["Aemulus", "New samples"]
param_labels = [r"$\Omega_m$", r"$\Omega_b$", r"$\sigma_8$", r"$h$", r"$n_s$", r"$N_{eff}$", r"$w_0$"]
sample_space([simulation_samples, new_samples_latent], param_labels, set_labels=set_labels)
[ ]: