snf_simulations.utils#
Utility functions for spectrum interpolation and sampling.
Module Contents#
Functions#
Linearly interpolate histogram content and propagate errors onto new bins. |
|
Sample x values from histogram bins, similar to ROOT TH1::GetRandom. |
API#
- snf_simulations.utils.linear_interpolate_with_errors(original_bins: numpy.ndarray, original_content: numpy.ndarray, original_errors: numpy.ndarray, new_bins: numpy.ndarray) tuple[numpy.ndarray, numpy.ndarray][source]#
Linearly interpolate histogram content and propagate errors onto new bins.
- snf_simulations.utils.sample_histogram(bin_edges: numpy.ndarray, bin_contents: numpy.ndarray, samples: int = 100, seed: int | None = None) numpy.ndarray[source]#
Sample x values from histogram bins, similar to ROOT TH1::GetRandom.
- Parameters:
bin_edges – 1D array of bin edges with length N+1.
bin_contents – 1D array of bin contents with length N.
samples – Number of samples to draw.
seed – Seed for reproducible random sampling.
- Returns:
Array of sampled x values.