Sampler#
- class gammapy.modeling.Sampler[source]#
Bases:
objectSampler class.
The sampler class provides a uniform interface to multiple sampler backends. Currently available: “ultranest” and “nautilus”.
Backend options are given in
options, with the backend’s own names. When the sampler runs, Gammapy passes each of them to the backend sampler constructor or to itsrunmethod, based on the signatures of the installed backend library. An unknown option raises an error listing the valid ones.- Parameters:
- backend{“ultranest”, “nautilus”}
Global backend used for sampler. Default is “ultranest”. UltraNest: Most options can be found in the UltraNest doc. Nautilus uses neural-network-guided nested sampling. See the Nautilus documentation.
- sampler_optsdict, optional
Deprecated since v2.2, use
optionsinstead. Default is None.- run_optsdict, optional
Deprecated since v2.2, use
optionsinstead. Default is None.- optionsdict, optional
Backend options, routed automatically. Default is None. See the options of UltraNest (constructor and
run) and of Nautilus.Gammapy defaults for “ultranest”:
log_dir=None,resume="subfolder",min_num_live_points=400,frac_remain=0.5.Gammapy defaults for “nautilus”:
n_live=2000,filepath=None,resume=True,f_live=0.01,n_eff=2000,verbose=True.
Notes
If you are using the “UltraNest” library, please follow its citation scheme: Cite UltraNest.
Examples
>>> from gammapy.modeling import Sampler >>> options = {"min_num_live_points": 300, "frac_remain": 0.3, "log_dir": None} >>> sampler = Sampler(backend="ultranest", options=options)
For a complete usage example, see Bayesian analysis with nested sampling tutorial.
Attributes Summary
Backend options, including the Gammapy defaults.
Options passed to the backend sampler run method.
Options passed to the backend sampler constructor.
Methods Summary
run(datasets)Run the sampler on the provided datasets.
Attributes Documentation
- options#
Backend options, including the Gammapy defaults.
- run_opts#
Options passed to the backend sampler run method.
Deprecated, use
optionsinstead. Accessing it imports the backend library.
- sampler_opts#
Options passed to the backend sampler constructor.
Deprecated, use
optionsinstead. Accessing it imports the backend library.
Methods Documentation
- run(datasets)[source]#
Run the sampler on the provided datasets.
- Parameters:
- datasets
Datasets Datasets to fit.
- datasets
- Returns:
- result
SamplerResult The sampler results. See the class description to get the exact content.
- result
- classmethod __new__(*args, **kwargs)#