JointNormalDistribution#

class pharmpy.model.JointNormalDistribution(names, level, mean, variance)[source]#

Bases: Distribution

Joint distribution of random variables

Parameters:
  • names (list) – Names of the random variables

  • level (str) – Variability level

  • mean (matrix or list) – Vector of the means of the random variables

  • variance (matrix or list of lists) – Covariance matrix of the random variables

Example

>>> from pharmpy.model import JointNormalDistribution, Parameter
>>> omega_cl = Parameter("OMEGA_CL", 0.1)
>>> omega_v = Parameter("OMEGA_V", 0.1)
>>> corr_cl_v = Parameter("OMEGA_CL_V", 0.01)
>>> dist = JointNormalDistribution.create(["IIV_CL", "IIV_V"], "IIV", [0, 0],
...     [[omega_cl.symbol, corr_cl_v.symbol], [corr_cl_v.symbol, omega_v.symbol]])
>>> dist
⎡IIV_CL⎤    ⎧⎡0⎤  ⎡ OMEGA_CL   OMEGA_CL_V⎤⎫
⎢      ⎥ ~ N⎪⎢ ⎥, ⎢                      ⎥⎪
⎣IIV_V ⎦    ⎩⎣0⎦  ⎣OMEGA_CL_V   OMEGA_V  ⎦⎭

Attributes Summary

free_symbols

Free symbols including random variable itself

level

Name of VariabilityLevel of the random variables

mean

names

Names of random variables of distribution

parameter_names

List of names of all parameters used in definition

variance

Methods Summary

create(names, level, mean, variance)

evalf(parameters)

from_dict(d)

get_covariance(name1, name2)

get_variance(name)

latex_string([aligned])

replace(**kwargs)

Replace properties and create a new JointNormalDistribution

subs(d)

Substitute expressions

to_dict()

Attributes Documentation

free_symbols#

Free symbols including random variable itself

level#
mean#
names#
parameter_names#

List of names of all parameters used in definition

variance#

Methods Documentation

classmethod create(names, level, mean, variance)[source]#
evalf(parameters)[source]#
classmethod from_dict(d)[source]#
get_covariance(name1, name2)[source]#
get_variance(name)[source]#
latex_string(aligned=False)[source]#
replace(**kwargs)[source]#

Replace properties and create a new JointNormalDistribution

subs(d)[source]#

Substitute expressions

Parameters:

d (dict) – Dictionary of from: to pairs for substitution

Examples

>>> import sympy
>>> from pharmpy.model import JointNormalDistribution, Parameter
>>> omega1 = Parameter("OMEGA_CL", 0.1)
>>> omega2 = Parameter("OMEGA_V", 0.1)
>>> A = [[omega1.symbol, 0], [0, omega2.symbol]]
>>> dist = JointNormalDistribution.create(["IIV_CL", "IIV_V"], "IIV", [0, 0], A)
>>> dist = dist.subs({omega1.symbol: sympy.Symbol("OMEGA_NEW")})
>>> dist
        ⎡IIV_CL⎤    ⎧⎡0⎤  ⎡OMEGA_NEW     0   ⎤⎫
        ⎢      ⎥ ~ N⎪⎢ ⎥, ⎢                  ⎥⎪
        ⎣IIV_V ⎦    ⎩⎣0⎦  ⎣    0      OMEGA_V⎦⎭
to_dict()[source]#