Error Models

Error models in chi model the deviations between experimental observations and the MechanisticModel predictions.

Classes

Detailed API

class chi.ConstantAndMultiplicativeGaussianErrorModel[source]

An error model which assumes that the model error is a mixture between a Gaussian base-level noise and a Gaussian heteroscedastic noise.

A mixture between a Gaussian base-level noise and a Gaussian heteroscedastic noise assumes that the measurable values \(y\) are related to the MechanisticModel output \(\bar{y}\) by

\[y(t, \psi , \sigma _{\text{base}}, \sigma _{\text{rel}}) = \bar{y} + \left( \sigma _{\text{base}} + \sigma _{\text{rel}} \, \bar{y}\right) \, \epsilon ,\]

where \(\bar{y}(t, \psi )\) is the mechanistic model output with parameters \(\psi\), and \(\epsilon\) is a i.i.d. standard Gaussian random variable

\[\epsilon \sim \mathcal{N}(0, 1).\]

As a result, this model assumes that the measured values \(y^{\text{obs}}\) are realisations of the random variable \(y\).

At each time point \(t\) the distribution of the measurable values can be expressed in terms of a Gaussian distribution

\[p(y | \psi , \sigma _{\text{base}}, \sigma _{\text{rel}}, t) = \frac{1}{\sqrt{2\pi} \sigma _{\text{tot}}} \mathrm{e}^{-\frac{\left(y-\bar{y}\right) ^2} {2\sigma^2 _{\text{tot}}}},\]

where \(\sigma _{\text{tot}} = \sigma _{\text{base}} + \sigma _{\text{rel}}\bar{y}\).

Extends ErrorModel.

compute_log_likelihood(parameters, model_output, observations)[source]

Returns the log-likelihood of the model parameters.

In this method the log-likelihood of the model parameters \((\psi , \sigma _{\text{base}}, \sigma _{\text{rel}})\) is computed based on the data \(\mathcal{D} = \{(y^{\text{obs}}_j, t_j)\} _{j=1}^n\)

\[L(\psi , \sigma _{\text{base}}, \sigma _{\text{rel}} | \mathcal{D}) = \sum _{j=1}^n \log p(y^{\text{obs}} _j | \psi , \sigma _{\text{base}}, \sigma _{\text{rel}}, t_j) ,\]

where \(n\) is the number of observations, \(y^{\text{obs}}\) the measured values and \(t_j\) the measurement time points.

The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the entries correspond to the same times.

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • observations – An array-like object with the measured values.

compute_pointwise_ll(parameters, model_output, observations)[source]

Returns the pointwise log-likelihood of the model parameters for each observation.

In this method the log-likelihood of the model parameters \((\psi , \sigma _{\text{base}}, \sigma _{\text{rel}})\) is computed pointwise for each data point \(\mathcal{D}_j = (y^{\text{obs}}_j, t_j)\)

\[L(\psi , \sigma _{\text{base}}, \sigma _{\text{rel}} | \mathcal{D}_j) = \log p(y^{\text{obs}} _j | \psi , \sigma _{\text{base}}, \sigma _{\text{rel}}, t_j) ,\]

where \(y^{\text{obs}}_j\) is the \(j^{\text{th}}\) measurement and \(t_j\) the associated measurement time point.

The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the first entries correspond to the same time, the second entries correspond to the same time, and so on.

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • observations – An array-like object with the measured values.

compute_sensitivities(parameters, model_output, model_sensitivities, observations)[source]

Returns the log-likelihood of the model parameters and its sensitivity w.r.t. the parameters.

In this method, the log-likelihood of the model parameters is computed. The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the first entries correspond to the same time, the second entries correspond to the same time, and so on.

The sensitivities of the log-likelihood are defined as the partial derivatives of \(L\) with respect to the model parameters \((\partial _{\psi} L, \partial _{\sigma} L)\).

Parameters:
  • parameters (list, numpy.ndarray of length 2) – An array-like object with the error model parameters.

  • model_output (list, numpy.ndarray of length t) – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • model_sensitivities (numpy.ndarray of shape (t, p)) – An array-like object with the partial derivatives of the model output w.r.t. the model parameters.

  • observations (list, numpy.ndarray of length t) – An array-like object with the measured values.

get_parameter_names()

Returns the names of the error model parameters.

n_parameters()

Returns the number of parameters of the error model.

sample(parameters, model_output, n_samples=None, seed=None)[source]

Returns samples from the mechanistic model-error model pair in form of a NumPy array of shape (len(model_output), n_samples).

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel.

  • n_samples – Number of samples from the error model for each entry in model_output. If None, one sample is assumed.

  • seed – Seed for the pseudo-random number generator. If None, the pseudo-random number generator is not seeded.

set_parameter_names(names=None)[source]

Sets the names of the error model parameters.

Parameters:

names – An array-like object with string-convertable entries of length n_parameters(). If None, parameter names are reset to defaults.

class chi.GaussianErrorModel[source]

An error model which assumes that the model error follows a Gaussian distribution.

A Gaussian error model assumes that the measurable values \(y\) are related to the MechanisticModel output \(\bar{y}\) by

\[y(t, \psi , \sigma) = \bar{y} + \sigma \epsilon ,\]

where \(\bar{y}(t, \psi )\) is the mechanistic model output with parameters \(\psi\), and \(\epsilon\) is a i.i.d. standard Gaussian random variable

\[\epsilon \sim \mathcal{N}(0, 1).\]

As a result, this model assumes that the measured values \(y^{\text{obs}}\) are realisations of the random variable \(y\).

At each time point \(t\) the distribution of the observable biomarkers can be expressed in terms of a Gaussian distribution

\[p(y | \psi , \sigma , t) = \frac{1}{\sqrt{2\pi} \sigma } \mathrm{e}^{-\frac{\left(y-\bar{y}\right) ^2} {2\sigma^2 }}.\]

Extends ErrorModel.

compute_log_likelihood(parameters, model_output, observations)[source]

Returns the log-likelihood of the model parameters.

In this method the log-likelihood of the model parameters \((\psi , \sigma )\) is computed based on the data \(\mathcal{D} = \{(y^{\text{obs}}_j, t_j)\} _{j=1}^n\)

\[L(\psi , \sigma | \mathcal{D}) = \sum _{j=1}^n \log p(y^{\text{obs}} _j | \psi , \sigma , t_j) ,\]

where \(n\) is the number of observations, \(y^{\text{obs}}\) the measured values and \(t_j\) the measurement time points.

The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the entries correspond to the same times.

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • observations – An array-like object with the measured values.

compute_pointwise_ll(parameters, model_output, observations)[source]

Returns the pointwise log-likelihood of the model parameters for each observation.

In this method the log-likelihood of the model parameters \((\psi , \sigma )\) is computed pointwise for each data point \(\mathcal{D}_j = (y^{\text{obs}}_j, t_j)\)

\[L(\psi , \sigma | \mathcal{D}_j) = \log p(y^{\text{obs}} _j | \psi , \sigma , t_j) ,\]

where \(y^{\text{obs}}_j\) is the \(j^{\text{th}}\) measurement and \(t_j\) the associated measurement time point.

The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the first entries correspond to the same time, the second entries correspond to the same time, and so on.

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • observations – An array-like object with the measured values.

compute_sensitivities(parameters, model_output, model_sensitivities, observations)[source]

Returns the log-likelihood of the model parameters and its sensitivity w.r.t. the parameters.

In this method, the log-likelihood of the model parameters is computed. The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the first entries correspond to the same time, the second entries correspond to the same time, and so on.

The sensitivities of the log-likelihood are defined as the partial derivatives of \(L\) with respect to the model parameters \((\partial _{\psi} L, \partial _{\sigma} L)\).

Parameters:
  • parameters (list, numpy.ndarray of length 2) – An array-like object with the error model parameters.

  • model_output (list, numpy.ndarray of length t) – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • model_sensitivities (numpy.ndarray of shape (t, p)) – An array-like object with the partial derivatives of the model output w.r.t. the model parameters.

  • observations (list, numpy.ndarray of length t) – An array-like object with the measured values.

get_parameter_names()

Returns the names of the error model parameters.

n_parameters()

Returns the number of parameters of the error model.

sample(parameters, model_output, n_samples=None, seed=None)[source]

Returns samples from the mechanistic model-error model pair in form of a NumPy array of shape (len(model_output), n_samples).

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel.

  • n_samples – Number of samples from the error model for each entry in model_output. If None, one sample is assumed.

  • seed – Seed for the pseudo-random number generator. If None, the pseudo-random number generator is not seeded.

set_parameter_names(names=None)[source]

Sets the names of the error model parameters.

Parameters:

names – An array-like object with string-convertable entries of length n_parameters(). If None, parameter names are reset to defaults.

class chi.LogNormalErrorModel[source]

An error model which assumes that the model error follows a Log-normal distribution.

A log-normal error model assumes that the measurable values \(y\) are related to the MechanisticModel output \(\bar{y}\) by

\[y(t, \psi , \sigma _{\mathrm{log}}) = \bar{y} \, \mathrm{e}^{ \mu _{\mathrm{log}} + \sigma _{\mathrm{log}} \varepsilon },\]

where \(\bar{y}(t, \psi )\) is the mechanistic model output with parameters \(\psi\), and \(\varepsilon\) is a i.i.d. standard Gaussian random variable

\[\varepsilon \sim \mathcal{N}(0, 1).\]

Here, \(\sigma _{\mathrm{log}}\) is the standard deviation of \(\log y\) and \(\mu _{\mathrm{log}} := -\sigma _{\mathrm{log}} ^2 / 2\) is chosen such that the expected measured value is equal to the model output

\[\mathbb{E}[y] = \bar{y}.\]

As a result, this model assumes that the measured values \(y^{\text{obs}}\) are realisations of the random variable \(y\).

At each time point \(t\) the distribution of the observable biomarkers can be expressed in terms of a log-normal distribution

\[p(y | \psi , \sigma _{\mathrm{log}} , t) = \frac{1}{\sqrt{2\pi} \sigma _{\mathrm{log}} y} \exp{\left(-\frac{ \left(\log y - \log \bar{y} + \sigma _{\mathrm{log}}^2/2\right) ^2} {2\sigma _{\mathrm{log}}^2 } \right)}.\]

Extends ErrorModel.

compute_log_likelihood(parameters, model_output, observations)[source]

Returns the log-likelihood of the model parameters.

In this method the log-likelihood of the model parameters \((\psi , \sigma _{\mathrm{log}})\) is computed based on the data \(\mathcal{D} = \{(y^{\text{obs}}_j, t_j)\} _{j=1}^n\)

\[L(\psi , \sigma _{\mathrm{log}}| \mathcal{D}) = \sum _{j=1}^n \log p(y^{\text{obs}} _j | \psi , \sigma _{\mathrm{log}}, t_j) ,\]

where \(n\) is the number of observations, \(y^{\text{obs}}\) the measured values and \(t_j\) the measurement time points.

The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the entries correspond to the same times.

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • observations – An array-like object with the measured values.

compute_pointwise_ll(parameters, model_output, observations)[source]

Returns the pointwise log-likelihood of the model parameters for each observation.

In this method the log-likelihood of the model parameters \((\psi , \sigma _{\mathrm{log}} )\) is computed pointwise for each data point \(\mathcal{D}_j = (y^{\text{obs}}_j, t_j)\)

\[L(\psi , \sigma _{\mathrm{log}} | \mathcal{D}_j) = \log p(y^{\text{obs}} _j | \psi , \sigma _{\mathrm{log}} , t_j) ,\]

where \(y^{\text{obs}}_j\) is the \(j^{\text{th}}\) measurement and \(t_j\) the associated measurement time point.

The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the first entries correspond to the same time, the second entries correspond to the same time, and so on.

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • observations – An array-like object with the measured values.

compute_sensitivities(parameters, model_output, model_sensitivities, observations)[source]

Returns the log-likelihood of the model parameters and its sensitivity w.r.t. the parameters.

In this method, the log-likelihood of the model parameters is computed. The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the first entries correspond to the same time, the second entries correspond to the same time, and so on.

The sensitivities of the log-likelihood are defined as the partial derivatives of \(L\) with respect to the model parameters \((\partial _{\psi} L, \partial _{\sigma} L)\).

Parameters:
  • parameters (list, numpy.ndarray of length 2) – An array-like object with the error model parameters.

  • model_output (list, numpy.ndarray of length t) – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • model_sensitivities (numpy.ndarray of shape (t, p)) – An array-like object with the partial derivatives of the model output w.r.t. the model parameters.

  • observations (list, numpy.ndarray of length t) – An array-like object with the measured values.

get_parameter_names()

Returns the names of the error model parameters.

n_parameters()

Returns the number of parameters of the error model.

sample(parameters, model_output, n_samples=None, seed=None)[source]

Returns samples from the mechanistic model-error model pair in form of a NumPy array of shape (len(model_output), n_samples).

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel.

  • n_samples – Number of samples from the error model for each entry in model_output. If None, one sample is assumed.

  • seed – Seed for the pseudo-random number generator. If None, the pseudo-random number generator is not seeded.

set_parameter_names(names=None)[source]

Sets the names of the error model parameters.

Parameters:

names – An array-like object with string-convertable entries of length n_parameters(). If None, parameter names are reset to defaults.

class chi.MultiplicativeGaussianErrorModel[source]

An error model which assumes that the model error is a Gaussian heteroscedastic noise.

A Gaussian heteroscedastic noise model assumes that the measurable values \(y\) are related to the MechanisticModel output \(\bar{y}\) by

\[y(t, \psi , \sigma _{\text{rel}}) = \bar{y} + \bar{y} \sigma _{\text{rel}} \, \epsilon ,\]

where \(\bar{y}(t, \psi )\) is the mechanistic model output with parameters \(\psi\), and \(\epsilon\) is a i.i.d. standard Gaussian random variable

\[\epsilon \sim \mathcal{N}(0, 1).\]

As a result, this model assumes that the observed biomarker values \(y^{\text{obs}}\) are realisations of the random variable \(y\).

At each time point \(t\) the distribution of the observable biomarkers can be expressed in terms of a Gaussian distribution

\[p(y | \psi , \sigma _{\text{base}}, \sigma _{\text{rel}}, t) = \frac{1}{\sqrt{2\pi} \sigma _{\text{tot}}} \exp{\left(-\frac{\left(y-\bar{y}\right) ^2} {2\sigma^2 _{\text{tot}}} \right)},\]

where \(\sigma _{\text{tot}} = \bar{y}\sigma _{\text{rel}}\).

Extends ErrorModel.

compute_log_likelihood(parameters, model_output, observations)[source]

Returns the log-likelihood of the model parameters.

In this method the log-likelihood of the model parameters \((\psi , \sigma _{\mathrm{rel}})\) is computed based on the data \(\mathcal{D} = \{(y^{\text{obs}}_j, t_j)\} _{j=1}^n\)

\[L(\psi , \sigma _{\mathrm{rel}}| \mathcal{D}) = \sum _{j=1}^n \log p(y^{\text{obs}} _j | \psi , \sigma _{\mathrm{rel}}, t_j) ,\]

where \(n\) is the number of observations, \(y^{\text{obs}}\) the measured values and \(t_j\) the measurement time points.

The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the entries correspond to the same times.

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • observations – An array-like object with the measured values.

compute_pointwise_ll(parameters, model_output, observations)[source]

Returns the pointwise log-likelihood of the model parameters for each observation.

In this method the log-likelihood of the model parameters \((\psi , \sigma _{\mathrm{rel}} )\) is computed pointwise for each data point \(\mathcal{D}_j = (y^{\text{obs}}_j, t_j)\)

\[L(\psi , \sigma _{\mathrm{rel}} | \mathcal{D}_j) = \log p(y^{\text{obs}} _j | \psi , \sigma _{\mathrm{rel}} , t_j) ,\]

where \(y^{\text{obs}}_j\) is the \(j^{\text{th}}\) measurement and \(t_j\) the associated measurement time point.

The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the first entries correspond to the same time, the second entries correspond to the same time, and so on.

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • observations – An array-like object with the measured values.

compute_sensitivities(parameters, model_output, model_sensitivities, observations)[source]

Returns the log-likelihood of the model parameters and its sensitivity w.r.t. the parameters.

In this method, the log-likelihood of the model parameters is computed. The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the first entries correspond to the same time, the second entries correspond to the same time, and so on.

The sensitivities of the log-likelihood are defined as the partial derivatives of \(L\) with respect to the model parameters \((\partial _{\psi} L, \partial _{\sigma} L)\).

Parameters:
  • parameters (list, numpy.ndarray of length 2) – An array-like object with the error model parameters.

  • model_output (list, numpy.ndarray of length t) – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • model_sensitivities (numpy.ndarray of shape (t, p)) – An array-like object with the partial derivatives of the model output w.r.t. the model parameters.

  • observations (list, numpy.ndarray of length t) – An array-like object with the measured values.

get_parameter_names()

Returns the names of the error model parameters.

n_parameters()

Returns the number of parameters of the error model.

sample(parameters, model_output, n_samples=None, seed=None)[source]

Returns samples from the mechanistic model-error model pair in form of a NumPy array of shape (len(model_output), n_samples).

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel.

  • n_samples – Number of samples from the error model for each entry in model_output. If None, one sample is assumed.

  • seed – Seed for the pseudo-random number generator. If None, the pseudo-random number generator is not seeded.

set_parameter_names(names=None)[source]

Sets the names of the error model parameters.

Parameters:

names – An array-like object with string-convertable entries of length n_parameters(). If None, parameter names are reset to defaults.

Base classes

Detailed API

class chi.ErrorModel[source]

A base class for error models for the one-dimensional output of MechanisticModel instances.

compute_log_likelihood(parameters, model_output, observations)[source]

Returns the log-likelihood of the model parameters.

In this method the log-likelihood of the model parameters \((\psi , \sigma )\) is computed based on the data \(\mathcal{D} = \{(y^{\text{obs}}_j, t_j)\} _{j=1}^n\)

\[L(\psi , \sigma | \mathcal{D}) = \sum _{j=1}^n \log p(y^{\text{obs}} _j | \psi , \sigma , t_j) ,\]

where \(n\) is the number of observations, \(y^{\text{obs}}\) the measured values and \(t_j\) the measurement time points.

The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the entries correspond to the same times.

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • observations – An array-like object with the measured values.

compute_pointwise_ll(parameters, model_output, observations)[source]

Returns the pointwise log-likelihood of the model parameters for each observation.

In this method the log-likelihood of the model parameters \((\psi , \sigma )\) is computed pointwise for each data point \(\mathcal{D}_j = (y^{\text{obs}}_j, t_j)\)

\[L(\psi , \sigma | \mathcal{D}_j) = \log p(y^{\text{obs}} _j | \psi , \sigma , t_j) ,\]

where \(y^{\text{obs}}_j\) is the \(j^{\text{th}}\) measurement and \(t_j\) the associated measurement time point.

The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the first entries correspond to the same time, the second entries correspond to the same time, and so on.

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • observations – An array-like object with the measured values.

compute_sensitivities(parameters, model_output, model_sensitivities, observations)[source]

Returns the log-likelihood of the model parameters and its sensitivity w.r.t. the parameters.

In this method, the log-likelihood of the model parameters is computed. The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the first entries correspond to the same time, the second entries correspond to the same time, and so on.

The sensitivities of the log-likelihood are defined as the partial derivatives of \(L\) with respect to the model parameters \((\partial _{\psi} L, \partial _{\sigma} L)\).

Parameters:
  • parameters (list, numpy.ndarray of length 2) – An array-like object with the error model parameters.

  • model_output (list, numpy.ndarray of length t) – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • model_sensitivities (numpy.ndarray of shape (t, p)) – An array-like object with the partial derivatives of the model output w.r.t. the model parameters.

  • observations (list, numpy.ndarray of length t) – An array-like object with the measured values.

get_parameter_names()[source]

Returns the names of the error model parameters.

n_parameters()[source]

Returns the number of parameters of the error model.

sample(parameters, model_output, n_samples=None, seed=None)[source]

Returns a samples from the mechanistic model-error model pair in form of a NumPy array of shape (len(model_output), n_samples).

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel.

  • n_samples – Number of samples from the error model for each entry in model_output. If None, one sample is assumed.

  • seed – Seed for the pseudo-random number generator. If None, the pseudo-random number generator is not seeded.

set_parameter_names(names=None)[source]

Sets the names of the error model parameters.

Parameters:

names – An array-like object with string-convertable entries of length n_parameters(). If None, parameter names are reset to defaults.

class chi.ReducedErrorModel(error_model)[source]

A class that can be used to permanently fix model parameters of an ErrorModel instance.

This may be useful to explore simplified versions of a model.

Parameters:

error_model – An instance of a ErrorModel.

compute_log_likelihood(parameters, model_output, observations)[source]

Returns the log-likelihood of the model parameters.

In this method the log-likelihood of the model parameters \((\psi , \sigma )\) is computed based on the data \(\mathcal{D} = \{(y^{\text{obs}}_j, t_j)\} _{j=1}^n\)

\[L(\psi , \sigma | \mathcal{D}) = \sum _{j=1}^n \log p(y^{\text{obs}} _j | \psi , \sigma , t_j) ,\]

where \(n\) is the number of observations, \(y^{\text{obs}}\) the measured values and \(t_j\) the measurement time points.

The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the entries correspond to the same times.

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • observations – An array-like object with the measured values.

compute_pointwise_ll(parameters, model_output, observations)[source]

Returns the pointwise log-likelihood of the model parameters for each observation.

In this method the log-likelihood of the model parameters \((\psi , \sigma )\) is computed pointwise for each data point \(\mathcal{D}_j = (y^{\text{obs}}_j, t_j)\)

\[L(\psi , \sigma | \mathcal{D}_j) = \log p(y^{\text{obs}} _j | \psi , \sigma , t_j) ,\]

where \(y^{\text{obs}}_j\) is the \(j^{\text{th}}\) measurement and \(t_j\) the associated measurement time point.

The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the first entries correspond to the same time, the second entries correspond to the same time, and so on.

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • observations – An array-like object with the measured values.

compute_sensitivities(parameters, model_output, model_sensitivities, observations)[source]

Returns the log-likelihood of the model parameters and its sensitivity w.r.t. the parameters.

In this method, the log-likelihood of the model parameters is computed. The time-dependence of the values is dealt with implicitly, by assuming that model_output and observations are already ordered, such that the first entries correspond to the same time, the second entries correspond to the same time, and so on.

The sensitivities of the log-likelihood are defined as the partial derivatives of \(L\) with respect to the model parameters \((\partial _{\psi} L, \partial _{\sigma} L)\).

Parameters:
  • parameters (list, numpy.ndarray of length 2) – An array-like object with the error model parameters.

  • model_output (list, numpy.ndarray of length t) – An array-like object with the one-dimensional output of a MechanisticModel. Each entry is a prediction of the mechanistic model for an observed time point in observations.

  • model_sensitivities (numpy.ndarray of shape (t, p)) – An array-like object with the partial derivatives of the model output w.r.t. the model parameters.

  • observations (list, numpy.ndarray of length t) – An array-like object with the measured values.

fix_parameters(name_value_dict)[source]

Fixes the value of model parameters, and effectively removes them as a parameter from the model. Fixing the value of a parameter at None, sets the parameter free again.

Parameters:

name_value_dict – A dictionary with model parameter names as keys, and parameter values as values.

get_error_model()[source]

Returns the original error model.

get_parameter_names()[source]

Returns the names of the error model parameters.

n_fixed_parameters()[source]

Returns the number of fixed model parameters.

n_parameters()[source]

Returns the number of parameters of the error model.

sample(parameters, model_output, n_samples=None, seed=None)[source]

Returns a samples from the mechanistic model-error model pair in form of a NumPy array of shape (len(model_output), n_samples).

Parameters:
  • parameters – An array-like object with the error model parameters.

  • model_output – An array-like object with the one-dimensional output of a MechanisticModel.

  • n_samples – Number of samples from the error model for each entry in model_output. If None, one sample is assumed.

  • seed – Seed for the pseudo-random number generator. If None, the pseudo-random number generator is not seeded.

set_parameter_names(names=None)[source]

Sets the names of the error model parameters.

Parameters:

names – An array-like object with string-convertable entries of length n_parameters(). If None, parameter names are reset to defaults.