Skip to content

distrib

The formulas of the distributions of the fitted parameters, without a simulator.

A fitted parameter carries the distribution of its draws as a formula of the SBML package distrib (pkpdsim.uncertainty.ParameterUncertainty.distribution): normal(mean, sd[, lower, upper]), lognormal(mu, sigma[, lower, upper]) (mu and sigma of the natural logarithm) and uniform(lower, upper), with numbers as arguments, truncated to the bounds of the fit when they are given. This module is the one grammar of these formulas: the draws of pkpdsim.uncertainty parse them into the distributions of sbmlsim, and the PBPK library reads their support to bound a fitted fraction (it must not import a simulator).

ARGUMENTS module-attribute

ARGUMENTS = {
    "normal": (2, 4),
    "lognormal": (2, 4),
    "uniform": (2,),
}

The distributions and their numbers of arguments; the last two of four are the bounds of a truncation.

DistribFormula dataclass

DistribFormula(name, args)

A formula of a distribution of distrib.

Attributes:

Name Type Description
name str

the distribution, a key of ARGUMENTS.

args tuple[float, ...]

the arguments.

bounds property

bounds

The bounds of a truncated or uniform distribution, None without.

parse

parse(formula)

Parse a formula of a distribution.

Parameters:

Name Type Description Default
formula str

e.g. normal(0.3, 0.05, 0.01, 0.6).

required

Returns:

Type Description
DistribFormula

The distribution and its arguments.

Raises:

Type Description
ValueError

if the formula is no function of numbers, or no distribution of ARGUMENTS with a supported number of arguments.

support

support(formula)

Get the support of a distribution: the values its draws can take.

Parameters:

Name Type Description Default
formula str

the formula of the distribution.

required

Returns:

Type Description
float

The bounds of a truncated or uniform distribution; without bounds

float

normal is unbounded and lognormal positive; a formula which

tuple[float, float]

parse refuses is unbounded (its values cannot be bounded).