aquakin.monte_carlo#

aquakin.monte_carlo(fn, distributions, *, input_names=None, output_names=None, n_samples=128, sampler='sobol', seed=0, batched=True)[source]#

Propagate uncertain inputs through fn and return the output ensemble.

Parameters:
  • fn (callable) – fn(x) -> output mapping an input vector x (shape (d,), in the order of distributions) to a scalar or (m,) vector output. As in aquakin.dgsm(), fn builds the params / initial state and runs the solve itself.

  • distributions (mapping or sequence) – One distribution per input, either a name -> spec mapping (then the keys are the input names) or a sequence of specs. Each spec is a (low, high) tuple (uniform) or a mapping {"dist": ...}uniform(low, high), normal(mean, std) or lognormal(mean, std) (mean / std in physical space).

  • input_names (sequence of str, optional) – Names for the input columns (defaults to the mapping keys or z0..) and output columns (defaults to output / y0..).

  • output_names (sequence of str, optional) – Names for the input columns (defaults to the mapping keys or z0..) and output columns (defaults to output / y0..).

  • n_samples (int) – Number of points to draw. For sampler='sobol' it is rounded to the nearest power of two.

  • sampler ({'sobol', 'lhs', 'random'}) – Low-discrepancy scrambled Sobol (default), Latin hypercube, or plain pseudo-random. Sampling is in the unit cube and mapped to the marginals by inverse-transform, so non-uniform inputs still get a good design.

  • seed (int) – Sampler seed; fixing it makes the result reproducible.

  • batched (bool) – Evaluate the whole sample through one jax.vmap() (default) or one call per point (lower peak memory).

Return type:

MonteCarloResult