Appraise#
Appraisal stage of the Neighbourhood Algorithm as in Sambridge 1999(II). Based on an approximation of the objective surface created by the Direct Search stage of the NA, the Appraisal stage resamples the approximation without needing to re-evaluate the objective function. This is a fast and efficient way to obtain more samples from the objective surface.
- class neighpy.appraise.NAAppraiser(n_resample: int, n_walkers: int = 1, searcher: neighpy.search.NASearcher | None = None, initial_ensemble: numpy.ndarray[Any, numpy.dtype[numpy._typing._generic_alias.ScalarType]] | None = None, log_ppd: numpy.ndarray[Any, numpy.dtype[numpy._typing._generic_alias.ScalarType]] | None = None, bounds: Optional[Tuple[Tuple[float, float], ...]] = None, verbose: bool = True, seed: int | None = None)#
Can be initialized with either a
NASearcherobject or theinitial_ensemble,log_ppdandbounds. If initialising with aNASearcherobject, theNASearcher.objectivesattribute will be assumed to be the negative log posterior probability density. For example, if the objective function used in theNASearcheris something like\[\Phi(\mathbf{m}) = (\mathbf{d} - \mathbf{G}(\mathbf{m}))^TC_d^{-1}(\mathbf{d} - \mathbf{G}(\mathbf{m}))\]i.e. the negative log-likelihood of a Gaussian data misfit. This will be passed to
NAAppraiseraslog_ppd = -NASearcher.objectives.- Parameters:
n_resample (int) – The number of resamples to use for the appraisal.
n_walkers (int) – The number of walkers to use in parallel.
searcher (NASearcher) – The searcher object used to generate the initial ensemble and log_ppd. If this is not None, the
initial_ensemble,log_ppdandboundswill be taken from this object.initial_ensemble (NDArray) – The initial ensemble of samples. Ignored if
searcheris not None.log_ppd (NDArray) – The log posterior probability values for each sample. Ignored if
searcheris not None.bounds (Tuple[Tuple[float, float], ...]) – The bounds of the parameter space. Ignored if
searcheris not None.verbose (bool) – Whether to display a progress bar.
seed (int) – Seed for the random number generator.
- run(save: bool = True, start_fraction: float = 0.5) None#
Perform the appraisal stage of the Neighbourhood Algorithm. Calculates a few basic MC integrals (mean, covariance and their errors).
- Parameters:
save – bool - whether to save the new samples from the appraisal. Set to :code:False to save memory, or if you only want a mean and covariance.
start_fraction – float - the fraction of the best cells to start the random walks from. This is used to avoid walking in low probability regions. Only used if
n_walkers > 1.
Populates the following attributes:
samples (NDArray) - the samples generated by the appraisal (if
save=True).mean (NDArray) - the mean of the samples.
sample_mean_error (NDArray) - the error in the mean.
covariance (NDArray) - the covariance of the samples.
sample_covariance_error (NDArray) - the error in the covariance.