mrpy.fitting.fit_sample.SimFit¶
-
class
mrpy.fitting.fit_sample.
SimFit
(m, nm=None, mmin=None, V=1.0, hs_bounds=(10, 16), alpha_bounds=(-1.99, -1.3), beta_bounds=(0.1, 2.0), lnA_bounds=(-40, -10), prior_func=None, prior_kwargs=None)¶ Per-object fits.
Parameters: m : array or list of arrays
Masses. Either an array or a list of arrays, each of which is a sample to be analysed simultaneously. In the latter case the samples should have the same underlying distribution, but may have differing truncation scales.
nm : array, optional
Specifies the number of occurrences of each variate in m (which should then ideally be unique). If not passed, each variate is assumed to occur once. This is useful for speeding up fits on quantized simulations. If m is a list of arrays, this should be also.
mmin : array_like, optional
The truncation mass of the sample. By default takes the lowest value of m. If m is a list of arrays, this should be a list.
V : array, optional
The volume of each subsample
hs_bounds, alpha_bounds, beta_bounds : 2-tuple
2-tuples specifying minimum and maximum values for each bound.
prior_func : function, optional
A function to calculate the likelihood arising from priors on the parameters. By default, uniform priors are assumed, which add nothing to the likelihood. The first parameter taken by the function should be the vector of parameter values,
[logHs,alpha,beta]
, after which arbitrary values are passed via prior_kwargs. It should return a tuple, with the first value being a float and constituting the likelihood arising from the prior, and the second being a 3-vector constituting the modification to the jacobian. This can be zero if no jacobian is desired.prior_kwargs : dict
Arguments sent to the prior_func.
Notes
Use as stringent bounds as possible, since the algorithm explores the edges, which can induce numerical error if values far from the solution are chosen.
Methods
__init__
(m[, nm, mmin, V, hs_bounds, …])lnL
(p[, ret_jac, debug])Return the log-likelihood of the current model at the parameters p. run_downhill
([hs0, alpha0, beta0, lnA0, …])Downhill-gradient optimization. run_mcmc
([nchains, warmup, iterations, hs0, …])Per-object MCMC fit for masses m, using the emcee package.