Skip to content

Esta página también está en español.

Léela en español

このページは日本語でも読めます。

日本語で読む

本页也有简体中文版本。

阅读简体中文版本

affine_sde_moments function

The mean and variance at time t of dX = (a + b X) dt + sigma dW, started at x0.

How to write it

affine_sde_moments(a, b, sigma, x0, time)

Gives {mean: ..., variance: ...}, with the case b = 0 apart; a note says when it holds.

a
The constant part of the drift. Takes an expression.
b
The rate: the drift is a + b X. Takes an expression.
sigma
The noise strength. Takes an expression.
x0
The starting value, which does not depend on time. Takes an expression.
time
The time, a variable. Takes a variable, or a list of variables.

affine_sde_moments(a, b, sigma, x0, time)

The same for up to six states; the answer has the mean and the covariance.

a
The constant part of the drift of each state, in brackets. Takes a list.
b
The matrix of the drift, one row for each state. Takes a matrix, written as a list of rows.
sigma
The noise: one row for each state, one column for each driver. Takes a matrix, written as a list of rows.
x0
The starting value of each state. Takes a list.
time
The time, a variable. Takes a variable, or a list of variables.

Examples

  • (E[Xt],Var⁡(Xt)) where dXt=(a+bXt) dt+σ dWt, X0=x0⇒E[Xt]={x0ebt+a(ebt−1)bif b≠0x0+atotherwiseVar⁡(Xt)={σ2(e2bt−1)2bif b≠0σ2totherwise\displaystyle (E[X_{t}], \operatorname{Var}(X_{t})) \text{ where } \mathrm{d}X_{t} = (a+b X_{t})\,\mathrm{d}t+\sigma\,\mathrm{d}W_{t},\ X_{0} = x_{0} \Rightarrow \begin{aligned} E[X_{t}] &= \begin{cases} x_{0} e^{b t}+\frac{a (e^{b t}-1)}{b} & \text{if } b \neq 0 \\ x_{0}+a t & \text{otherwise} \end{cases} \\ \operatorname{Var}(X_{t}) &= \begin{cases} \frac{\sigma^{2} (e^{2 b t}-1)}{2 b} & \text{if } b \neq 0 \\ \sigma^{2} t & \text{otherwise} \end{cases} \end{aligned}
    affine_sde_moments(a, b, sigma, x0, t)

    In the solver, affine_sde_moments(a, b, sigma, x0, t) gives {mean: piecewise(x0*e^(b*t) + a*(e^(b*t) - 1)/b if b != 0, x0 + a*t otherwise), variance: piecewise((1/2)sigma^2*(e^(2b*t) - 1)/b if b != 0, sigma^2*t otherwise)}.

    Open in the solver
  • (E[Xt],Var⁡(Xt)) where dXt=(1+2Xt) dt+3 dWt, X0=0⇒E[Xt]=e2t−12Var⁡(Xt)=9(e4t−1)4\displaystyle (E[X_{t}], \operatorname{Var}(X_{t})) \text{ where } \mathrm{d}X_{t} = (1+2 X_{t})\,\mathrm{d}t+3\,\mathrm{d}W_{t},\ X_{0} = 0 \Rightarrow \begin{aligned} E[X_{t}] &= \frac{e^{2 t}-1}{2} \\ \operatorname{Var}(X_{t}) &= \frac{9 (e^{4 t}-1)}{4} \end{aligned}
    affine_sde_moments(1, 2, 3, 0, t)

    In the solver, affine_sde_moments(1, 2, 3, 0, t) gives {mean: (e^(2t) - 1)/2, variance: 9(e^(4t) - 1)/4}.

    Open in the solver
  • affine_sde_moments⁡([0,0],(−120−3),(1001),[x0,y0],t)=[mean→[x0et+y0(e−t−1e3t),y0e3t],covariance→(−1e2t+12e4t−16e6t+23−14e4t+16e6t+112−14e4t+16e6t+11216−16e6t)]\displaystyle \operatorname{affine\_sde\_moments}\left(\left[ 0, 0 \right], \begin{pmatrix} -1 & 2 \\ 0 & -3 \end{pmatrix}, \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}, \left[ x_{0}, y_{0} \right], t\right) = \left[ \text{mean} \to \left[ \frac{x_{0}}{e^{t}}+y_{0} \left(e^{-t}-\frac{1}{e^{3 t}}\right), \frac{y_{0}}{e^{3 t}} \right], \text{covariance} \to \begin{pmatrix} -\frac{1}{e^{2 t}}+\frac{1}{2 e^{4 t}}-\frac{1}{6 e^{6 t}}+\frac{2}{3} & -\frac{1}{4 e^{4 t}}+\frac{1}{6 e^{6 t}}+\frac{1}{12} \\ -\frac{1}{4 e^{4 t}}+\frac{1}{6 e^{6 t}}+\frac{1}{12} & \frac{1}{6}-\frac{1}{6 e^{6 t}} \end{pmatrix} \right]
    affine_sde_moments([0, 0], [[-1, 2], [0, -3]], [[1, 0], [0, 1]], [x0, y0], t)

    In the solver, affine_sde_moments([0, 0], [[-1, 2], [0, -3]], [[1, 0], [0, 1]], [x0, y0], t) gives {mean: [x0*e^-t + y0*(e^-t - e^(-3t)), y0*e^(-3t)], covariance: [[-e^(-2t) + e^(-4t)/2 - e^(-6t)/6 + 2/3, -e^(-4t)/4 + e^(-6t)/6 + 1/12], [-e^(-4t)/4 + e^(-6t)/6 + 1/12, 1/6 - e^(-6t)/6]]}.

    Open in the solver
  • geometric_sde_path

    The path of dX = mu X dt + sigma X dW, as a function of the Wiener process's value w at time t.

  • binomial_distribution

    The number of successes in n independent trials that each succeed with chance p.

  • wiener_process

    Brownian motion with drift mu and noise sigma, started at 0.

  • cdf

    The probability that a variable with a distribution is at most a value.

  • weibull_distribution

    The lifetime of a unit whose chance of surviving to time x is e^(-(x/scale)^shape).

  • correlation

    The correlation coefficient of two lists of the same length.