ConditionalUniformPrior
- class dysmalpy.parameters.ConditionalUniformPrior(f_bounds=None, f_cond=<function _f_cond_boundaries>)[source]
Bases:
Prior
Object for flat priors, but with boundaries that are conditional on other model parameters.
Initialize
ConditionalUniformPrior
instance.- Parameters:
f_bounds (function) –
Function
f_bounds(param, modelset)
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.
f_cond (function, optional) –
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
If not set, it will default to a conditional based on the boundary function.
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