fit.priors¶
The joint prior of the parameters of a fit and the priors as distributions.
A parameter of a fit has the prior of FitParameter.prior, truncated at its
bounds, or else the uniform prior over its bounds. The priors are independent
unless the problem has a prior_correlation, a Covariance.correlation of
parameters which have a normal or a log-normal prior: the priors of these
parameters are one Gaussian copula with this correlation of their normal
scores (Nelsen 2006), i.e. the multivariate normal of their values (normal)
and of the logarithms of their values (log-normal), restricted to their
bounds. It is the dependence of the uncertainty analyses as well, see
sbmlsim.uncertainty.Covariance.
A fit of ObjectiveType.POSTERIOR minimizes the negative log posterior as a
sum of squares, JointPrior.residuals:
- an independent prior has the residual
sqrt(c - 2 log p)with the offsetcof_independent_term, so half its square minusc / 2is the negative log density of the prior truncated at the bounds; - the correlated priors are whitened (Tarantola 2005): with the normal scores
z = (v - mu) / sigmaof their valuesv(the logarithm of a log-normal one) and the Cholesky factorLof their correlationR = L L', the residualsw = L⁻¹ zhave the half sum of squaresz' R⁻¹ z / 2, the quadratic form of the multivariate normal; a log-normal prior has the residualsqrt(c + 2 ln(x))of the density of the logarithm in the value,1 / x. The density of correlated priors is normalized as the multivariate normal without the bounds, so the cost is the negative log posterior up to a constant of the problem, which neither the estimate, its profiles nor its Laplace approximation depend on.
prior_distributions and prior_model give the priors of a problem as the
distributions of the designs of sbmlsim.simulation.sampling and as the
UncertaintyModel of a propagation: a prior truncated at the bounds of its
parameter, the uniform distribution over the bounds for a parameter without
one, and the correlation of the problem. The marginals of correlated priors
are truncated each at its bounds, which equals the joint prior of the fit
where the bounds leave the priors untouched.
Nelsen RB (2006). An Introduction to Copulas, 2nd ed. Springer. Tarantola A (2005). Inverse Problem Theory and Methods for Model Parameter Estimation. SIAM.
JointPrior
¶
The prior of the parameters of a problem, see the module.
Create the prior of the parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
Sequence[FitParameter]
|
the parameters of the problem. |
required |
correlation
|
Covariance | None
|
the correlation of the normal scores of some of their priors, see the module. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
for a correlation the priors do not take, see
|
residuals
¶
Get the residuals of the prior, see the module.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
values of the parameters on the linear scale. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
The residuals, |
float
|
the bounds of a truncated prior, and the offset, so that half the |
tuple[ndarray, float]
|
sum of squares minus the offset is the negative log density. |
log_density
¶
Get the log density of the prior.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
values of the parameters on the linear scale. |
required |
Returns:
| Type | Description |
|---|---|
float
|
The log density, |
float
|
correlated priors are normalized without their bounds, see the |
float
|
module. |
check_prior_correlation
¶
Check that the priors of the parameters take a correlation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
Sequence[FitParameter]
|
the parameters of a problem. |
required |
correlation
|
Covariance | None
|
the correlation of their priors, nothing to check without. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
see |
prior_distributions
¶
Get the priors of the parameters of a problem as distributions of their targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
OptimizationProblem
|
the problem, initialized, so the units of its parameters are
the units of pint of its models, see
|
required |
targets
|
Mapping[str, str] | None
|
pid -> the target of the model, overrides
|
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Distribution]
|
target -> its prior truncated at the bounds of its parameter, or the |
dict[str, Distribution]
|
uniform distribution over the bounds for a parameter without a prior, |
dict[str, Distribution]
|
in the unit of the parameter. |
Raises:
| Type | Description |
|---|---|
ValueError
|
for a parameter without a prior whose bounds are not finite, a prior without a distribution of the sampler, or two parameters of one target (the versions of a parameter). |
prior_model
¶
Get the priors of the parameters of a problem as the uncertainty of a propagation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problem
|
OptimizationProblem
|
the problem, initialized, see |
required |
targets
|
Mapping[str, str] | None
|
pid -> the target of the model, overrides
|
None
|
kwargs
|
Any
|
the other fields of the |
{}
|
Returns:
| Type | Description |
|---|---|
UncertaintyModel
|
The model with the priors of |
UncertaintyModel
|
of the priors of the problem, by the targets. |