astrovascpy.ou¶
Functions
|
Zero finder function to compute the value of kappa and sigma. |
|
Calculate the expected time to reach x_max starting from x_0=0. |
|
Monte Carlo simulation of the OU process with a reflecting boundary at zero. |
- astrovascpy.ou.compute_OU_params(time, x_max, c)¶
Zero finder function to compute the value of kappa and sigma.
- astrovascpy.ou.expected_time(kappa, x_max, C, Nspace=10000)¶
Calculate the expected time to reach x_max starting from x_0=0.
We assume that x_max = C sigma/ sqrt(2 kappa) The code solves the ODE:
-kappa x U’(x) + 1/2 sigma^2 U’’(x) = -1
with U’(0)=0 and U(x_max) = 0 We use backward discretization for the first order derivative. Using the BC we get U(-1)=U(0) and U(N)=0. In matrix form, we solve: DU = -1, with tri-diagonal matrix D.
- astrovascpy.ou.ornstein_uhlenbeck_process(kappa, sigma, dt, iterations=1, zero_noise_time=1, seed=1234)¶
Monte Carlo simulation of the OU process with a reflecting boundary at zero.
- Stochastic differential equation:
dX(t) = - kappa X(t) dt + sigma dW
- with solution:
X(t+dt) = X(t) * exp(-kappa dt) + alpha * epsilon(t)
where: alpha = sqrt( sigma^2 / (2kappa) * (1-exp(-2*kappa*dt)) ) alpha is the standard deviation of epsilon. epsilon is a standard Gaussian random variable. The process starts at X(0) = 0
- Parameters:
- Returns:
Reflected OU process starting at zero.
- Return type:
numpy.array