6

Following the previously published question, I'm looking for the solution of RecurrenceTable with explicit random variable. For example, something like

RecurrenceTable[{y[n + 1] == y[n] ξ[n] + Sqrt[y[n]] ξ[n]^2, 
ξ[n] == RandomVariate[NormalDistribution[]], y[1] == 1}, {y}, {n, 1, 10}]

Of cause, the random variable has to be updated at each step.

Update: The long-term goal is the implicit Milstein solution for stochastic differential equations (SDE), since the current Mathematica version (10.3) supports only explicit solutions.

Moshe Gueta
  • 183
  • 6

1 Answers1

4

You can avoid pre-evaluation with the following definition

ξ[n_Integer] := RandomVariate[NormalDistribution[]]

RecurrenceTable[{y[n + 1] == y[n] ξ[n] + Sqrt[y[n]] ξ[n]^2, 
  y[1] == 1}, {y}, {n, 1, 10}]
(* {{1}, {1.39139}, {2.06846}, {0.0207897}, {0.0337668}, {0.18907}, \
{-0.193236}, {0.315955 + 0.300832 I}, {0.742221 + 0.264775 I}, {0.775734 + 
   0.220208 I}} *)

See also User-defined functions, numerical approximation, and NumericQ.

Note: each evaluation of ξ[n] gives different value. You can avoid it with the following modifications

ClearAll[ξ]
ξ[n_Integer] := ξ[n] = RandomVariate[NormalDistribution[]]

ClearAll[ξ]
rnd = RandomVariate[NormalDistribution[], 10];
ξ[n_Integer] := rnd[[n]]
ybeltukov
  • 43,673
  • 5
  • 108
  • 212