Samplers¶
- class ionworkspipeline.samplers.Sampler(**kwargs: Any)¶
Base class for all monte-carlo style samplers.
Samplers explore the parameter space to identify posterior distributions, whereas optimizers provide a point-based solution.
Parameters¶
- **kwargs
Arguments passed to the underlying sampling algorithm.
Extends:
ionworkspipeline.data_fits.parameter_estimators.parameter_estimator.ParameterEstimator- run(x0: ndarray) SamplerResult¶
Run the sampling algorithm to explore the parameter space.
Parameters¶
- x0
Initial point to start the Markov chain or sampling process.
Returns¶
- SamplerResult
The result of the sampling, containing the chain of samples and their associated costs/likelihoods.
- class ionworkspipeline.samplers.Pints(method: str = 'DramACMC', log_to_screen: bool = False, max_iterations: int = 1000, burnin_iterations: int | None = None, initial_phase_iterations: int | None = None, **kwargs)¶
Sampler using the Pints library: Probabilistic Inference for Bayesian Models.
Wraps Pints’ MCMCController class for MCMC sampling.
Parameters¶
- methodstr, optional
Sampling method. Default is “DramACMC”. Must be one of: “DramACMC”, “HamiltonianMCMC”, “HaarioBardenetACMC”, “MALAMCMC”, “MetropolisRandomWalkMCMC”, “MonomialGammaHamiltonianMCMC”, “NoUTurnMCMC”, “PopulationMCMC”, “RelativisticMCMC”, “SliceDoublingMCMC”, “SliceRankShrinkingMCMC”, or “SliceStepoutMCMC”.
- log_to_screenbool, optional
Whether to print information at runtime. Default is False.
- max_iterationsint, optional
Maximum number of iterations. Default is 1000.
- burnin_iterationsint, optional
Number of initial iterations to discard. Default is 10% of max_iterations.
- initial_phase_iterationsint, optional
Number of iterations in initial phase. Only used for methods that need an initial phase. Default is equal to burnin_iterations.
- **kwargs
Additional parameters passed to the pints MCMC sampler. See pints documentation for details.
Notes¶
The log PDF values are cached internally to work around a pints limitation.
For methods that need an initial phase, initial_phase_iterations must not exceed burnin_iterations, which in turn must not exceed max_iterations.
Extends:
ionworkspipeline.data_fits.parameter_estimators.samplers.sampler.Sampler- run(x0)¶
Sample the objective function.
Parameters¶
- x0array_like
Initial parameter values to start sampling from.
Returns¶
- SamplerResult:
The result of the sampling, containing: - samples: Array of shape (n_iterations, n_parameters) containing all samples - cost: Array of shape (n_iterations,) containing log probability densities - x: The parameter values with highest log probability - iterations: Number of iterations performed
- set_objective(objective)¶
Set the objective function to be minimized.
- class ionworkspipeline.samplers.GridSearch(npts: int = 10)¶
Grid search sampler - explores parameter space on a regular grid.
Evaluates the objective at all combinations of grid points across dimensions.
Parameters¶
- nptsint, optional
Number of points to use in each dimension. Default is 10.
Extends:
ionworkspipeline.data_fits.parameter_estimators.samplers.sampler.Sampler- run(x0: ndarray) SamplerResult¶
Run the sampling algorithm to explore the parameter space.
Parameters¶
- x0
Initial point to start the Markov chain or sampling process.
Returns¶
- SamplerResult
The result of the sampling, containing the chain of samples and their associated costs/likelihoods.
- class ionworkspipeline.samplers.PointEstimate¶
Point estimate sampler - returns the initial guess as a single sample.
Useful for evaluating a single parameter set within a sampling framework.
Extends:
ionworkspipeline.data_fits.parameter_estimators.samplers.sampler.Sampler- run(x0: ndarray) SamplerResult¶
Run the sampling algorithm to explore the parameter space.
Parameters¶
- x0
Initial point to start the Markov chain or sampling process.
Returns¶
- SamplerResult
The result of the sampling, containing the chain of samples and their associated costs/likelihoods.
- class ionworkspipeline.samplers.Dummy(*args, **kwargs)¶
Alias for PointEstimate sampler.
Extends:
ionworkspipeline.data_fits.parameter_estimators.samplers.point_estimate_sampler.PointEstimate