ConditionalEmpiricalUniformPrior
- class dysmalpy.parameters.ConditionalEmpiricalUniformPrior(f_cond=None, f_bounds=<function _f_boundaries_from_cond>)[source]
Bases:
Prior
Object for flat priors, but with boundaries that are conditional on other model parameters. Determined through empirical testing of f_cond, and bounds are then inferred based on iterating f_cond.
Initialize ConditionalEmpiricalUniformPrior instance.
- Parameters:
f_cond (function) – Function
f_cond(param, modelset, self.f_bounds)
that takes the parameter and model set as input. It must return True/False if the value does / does not satisfy the conditional requirements. IfTrue
, then the log prior will be 0., ifFalse
, then it will be-np.inf
f_bounds (function, optional) –
Function
f_bounds(param, modelset, self.f_cond)
that takes the parameter and model set as input. It must return a 2-element array with the lower, upper bounds for the parameter, for the given other model parameter settings. These will then be used to uniformly sample the parameter within these bounds.Note this will not be perfect, given the other parameters will be perturbed within their priors (and thus some of the sampled value tuples may end up in the bad region), but hopefully the MCMC walkers will still be able to work with this.
If not set, it will default to a function that iterates to find boundaries based on
self.f_cond
.
Methods Summary
log_prior
(param[, modelset])Returns the log value of the prior given the parameter value
prior_unit_transform
(param, u[, modelset])Map a uniform random variable drawn from [0.,1.] to the prior of interest
sample_prior
(param[, N, modelset])Returns a random sample of parameter values distributed according to the prior
Methods Documentation
- log_prior(param, modelset=None, **kwargs)[source]
Returns the log value of the prior given the parameter value
- Parameters:
param (
DysmalParameter
) –DysmalParameter
object with which the prior is associatedmodelset (
ModelSet
) – CurrentModelSet
, of which param is a part
- Returns:
lprior – Log prior value. 0 if the parameter value is within the bounds otherwise
-np.inf
- Return type:
0
or-np.inf
- prior_unit_transform(param, u, modelset=None, **kwargs)[source]
Map a uniform random variable drawn from [0.,1.] to the prior of interest
- sample_prior(param, N=1, modelset=None, **kwargs)[source]
Returns a random sample of parameter values distributed according to the prior
- Parameters:
param (
DysmalParameter
) –DysmalParameter
object with which the prior is associatedN (int, optional) – Size of random sample. Default is 1.
- Returns:
rsamp – Random sample of parameter values
- Return type:
float or array