kipe.parameters module
Estimated parameters: priors and reparameterization.
kipe estimates the reparameterized parameters \(\theta\), the forward solver receives the
physical values \(\phi\). Parameterization maps between the two.
- class kipe.parameters.EstimatedParameter(name: str, reparameterization: Reparameterization, anchor: float, stddev_theta: float)[source]
Bases:
objectOne estimated parameter: its reparameterization, the parameter value at which the reparameterization is anchored, and the standard deviation of \(\theta\).
- Raises:
ValueError – if the anchor is not admissible for the reparameterization
- name: str
Name of the parameter, as the forward solver knows it.
- reparameterization: Reparameterization
- anchor: float
The physical value \(\phi^0\) that \(\theta\) is relative to, e.g., \(\phi = \phi^0 \, e^\theta\) for
log: the prior mean. It stays fixed: outer iterations continue in the same \(\theta\), and the sensitivity analysis evaluates at the nominal values in it (to_theta()).
- stddev_theta: float
Initial standard deviation of \(\theta\).
- anchor_theta() float[source]
Return \(\theta\) at the anchor, the prior mean, where the first outer iteration starts: 0, or 1 for
multiplicative.- Returns:
\(\theta\) at the anchor
- to_physical(theta: float) float[source]
Map \(\theta\) to the physical value.
- Parameters:
theta – reparameterized parameter
- Returns:
physical value
- to_theta(phi: float) float[source]
Map the physical value to \(\theta\), the inverse of
to_physical().- Parameters:
phi – physical value
- Returns:
reparameterized parameter
- Raises:
ValueError – for
log, if the value does not have the sign of the anchor
- derivative(theta: float) float[source]
Return the derivative of the physical value by \(\theta\), \(\mathrm{d}\phi / \mathrm{d}\theta\).
It takes a standard deviation of \(\theta\) to one of the physical value, to first order, e.g., to compare the covariances of estimations with different anchors.
- Parameters:
theta – reparameterized parameter
- Returns:
\(\phi\) for
log, the anchor \(\phi^0\) formultiplicative, 1 foradditive
- theta_step(step: float) float[source]
Return the step in \(\theta\) corresponding to a step in the parameter.
With
log,stepis a relative change of the parameter, at any value; withmultiplicative, a change by that fraction of its anchor, the prior mean; withadditive, a fraction of the parameter’s prior standard deviation, which gives the step its unit:log: \(h_\theta = h\), to first order;multiplicative: \(h_\theta = h\);additive: \(h_\theta = h \sigma_\theta\).
Used by the sensitivity analysis (
kipe.sensitivity), which takes the steps at the nominal values.- Parameters:
step – relative change of the parameter (
log) or fraction of its prior mean (multiplicative), or fraction of its prior standard deviation (additive)- Returns:
step in \(\theta\)
- class kipe.parameters.Parameterization(parameters: list[EstimatedParameter])[source]
Bases:
objectThe estimated parameters as one vector \(\theta\), in the order of the study file.
Converts \(\theta\) to the physical values passed to the forward solver (
to_physical()), each entry by its parameter’s reparameterization, relative to its anchor, the prior mean (EstimatedParameter.anchor), and back (to_theta()). \(\theta\) is the same in all outer iterations and in the sensitivity analysis.- parameters: list[EstimatedParameter]
The estimated parameters, in the order of the entries of \(\theta\).
- property names: list[str]
Names of the estimated parameters.
- stddev_theta() NDArray_f64[source]
Return the initial standard deviations of \(\theta\).
- Returns:
initial standard deviations of \(\theta\)
- theta_step(step: float) NDArray_f64[source]
Return the steps in \(\theta\) of a step in the parameters, one per parameter.
- Parameters:
step – the step, see
EstimatedParameter.theta_step()- Returns:
the step in \(\theta\) of each parameter
- derivative(theta: NDArray_f64) NDArray_f64[source]
Return the derivative of each physical value by its \(\theta\), see
EstimatedParameter.derivative().- Parameters:
theta – reparameterized parameters, in the order of
parameters- Returns:
\(\mathrm{d}\phi_i / \mathrm{d}\theta_i\) of each parameter, the diagonal of the Jacobian
- anchor_theta() NDArray_f64[source]
Return \(\theta\) at the anchors, the prior means, where the first outer iteration starts.
- Returns:
\(\theta\) at the anchors
- to_physical(theta: NDArray_f64) Parameters[source]
Map \(\theta\) to physical values, as passed to the forward solver.
- Parameters:
theta – reparameterized parameters, in the order of
parameters- Returns:
parameter name -> physical value
- to_theta(physical: Parameters) NDArray_f64[source]
Map physical values to \(\theta\), the inverse of
to_physical().- Parameters:
physical – parameter name -> physical value
- Returns:
reparameterized parameters, in the order of
parameters
- one_sigma_range() list[tuple[float, float]][source]
Return the physical values at \(\theta\) of the anchors \(\pm \sigma_\theta\).
Shows what the uncertainty means in physical terms. Asymmetric around the anchor for
log.- Returns:
(lower, upper) physical value per parameter
- physical_range(theta: NDArray_f64, stddev_theta: NDArray_f64) list[tuple[float, float]][source]
Return the physical values at \(\theta \pm \sigma_\theta\).
- Parameters:
theta – estimated parameters, in the order of
parametersstddev_theta – their standard deviations
- Returns:
(lower, upper) physical value per parameter
- kipe.parameters.build_parameterization(options: ParametersOptions, available_parameters: Collection[str]) Parameterization[source]
Check the selected parameters against the solver’s and build the parameterization.
- Parameters:
options –
parameterssection of the study fileavailable_parameters – the names of the forward solver’s parameters (
nominal_parameters()), to check the selection against
- Returns:
the parameterization, with the parameters in the order of
options.priors- Raises:
StudyFileError – if a selected parameter is unknown to the solver, or a prior mean is not admissible for its reparameterization