utils.integrator_integrals module

Facilities to compute, estimate and benchmark integrals performed with Integrator objects

class IntegratorSampler(*args, **kwargs)[source]

Bases: utils.integral_validation.Sampler

Sampler using an Integrator’s sample_refine method

Parameters
  • integrator (zunis.integration.flat_survey_integrator.PosteriorSurveySamplingIntegrator) –

  • train (bool) – whether to train the integrator by running integrator.survey

  • n_survey_steps (int, None) – if train is True, how many survey steps to use for training. If None, use the configuration set at the creation of the Integrator

  • survey_args (None or dict) – if train is True, additional survey options to pass to integrator.survey

get_history()[source]

Get the integrator’s training history

Returns

Return type

pandas.Dataframe

sample(f, n_batch=10000, *args, **kwargs)[source]
Parameters
  • f (utils.integrands.Integrand) –

  • n_batch (int) –

Returns

  • tuple of torch.Tensor

  • x,px,fx (points, pdfs, function values)

train_integrator(n_survey_steps=None, survey_args=None)[source]

Train the integrator before sampling

Parameters
  • n_survey_steps (int) – if train is True, how many survey steps to use for training

  • survey_args (None or dict) – if train is True, additional survey options to pass to integrator.survey

evaluate_integral_integrator(f, integrator, n_batch=10000, train=True, n_survey_steps=None, survey_args=None, keep_history=False)[source]

Validate a known integral using an integrator as a sampler

Parameters
  • f (utils.integrands.KnownIntegrand) –

  • integrator (zunis.integration.flat_survey_integrator.PosteriorSurveySamplingIntegrator) –

  • n_batch (int) –

  • train (bool) – whether to train the integrator using integrator.survey

  • n_survey_steps (int, optional) – positional integrator.survey argument. Use the attribute n_iter_survey set at instantiation if not specified.

  • survey_args (None or dict) – optional keyword-argument dictionary for integrator.survey

  • keep_history (bool) – whether to keep track of the training history

Returns

Return type

utils.record.EvaluationRecord

validate_integral_integrator(f, integrator, n_batch=10000, sigma_cutoff=2, train=True, n_survey_steps=None, survey_args=None, keep_history=False)[source]

Validate a known integral using an integrator as a sampler

Parameters
  • f (utils.integrands.KnownIntegrand) –

  • integrator (zunis.integration.adaptive_survey_integrator.AdaptiveSurveyIntegrator) –

  • n_batch (int) –

  • sigma_cutoff (int) –

  • train (bool) – whether to train the integrator using integrator.survey

  • n_survey_steps (int) – positional integrator.survey argument

  • survey_args (None or dict) – optional keyword-argument dictionary for integrator.survey

  • keep_history (bool) – whether to keep track of the training history

Returns

Return type

utils.record.ComparisonRecord