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
affine_sde_moments(a, b, sigma, x0, t)In the solver,
Open in the solveraffine_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)}.affine_sde_moments(1, 2, 3, 0, t)In the solver,
Open in the solveraffine_sde_moments(1, 2, 3, 0, t)gives{mean: (e^(2t) - 1)/2, variance: 9(e^(4t) - 1)/4}.affine_sde_moments([0, 0], [[-1, 2], [0, -3]], [[1, 0], [0, 1]], [x0, y0], t)In the solver,
Open in the solveraffine_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]]}.
Related functions
- 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.