scippuncertainty.mc.driver.run#
- scippuncertainty.mc.driver.run(fn, *, n_samples, samplers, accumulators=None, n_threads=1, seed=None, progress=None, description='Monte-Carlo')[source]#
Propagate uncertainties using Monte-Carlo.
This function drives the propagation by drawing samples, calling the provided function on each, anc accumulating the results.
- Parameters:
fn (
Callable[...,dict[str,DataArray] |SkipSampleType]) – Function to perform the calculation that you want to propagate uncertainties through.n_samples (
int) – Number of samples to draw in total.samplers (
dict[str,Sampler]) – Dict of samplers to generate the input data. Samples are passed tofnby keyword arguments according to the keys in this dict.accumulators (
Optional[dict[str,Accumulator]], default:None) – Dict of accumulators for the results. Each item in the output offnis passed to the accumulator with the same key.n_threads (
int, default:1) – Number of threads. Settingn_threadsto something higher than 1 only makes sense iffnspends a significant amount of time in code that releases the GIL (e.g. most functions in Scipp).seed (
Union[Generator,list[Generator],int,list[int],SeedSequence,None], default:None) – Used to seed one random number generator per thread. Seescippuncertainty.random.make_rngs()for details.progress (
Optional[bool], default:None) – IfTrue, show progress bars in the terminal. This requires the packagerich. IfFalse, no progress is shown. IfNone, the default, progress bars are shown if and only ifrichis installed.description (
str, default:'Monte-Carlo') – Message to display in progress bars.
- Returns:
MCResult– Dict of results obtained from the accumulators. It contains one item per accumulator with the same key.