# Random Variable in Recurrence Function

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}, {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.

• This would be better described by some functions related to RandomProcess Nov 18, 2015 at 9:30
• Probably FoldList may be helpful, but I still do not understand how to implement it. Nov 18, 2015 at 13:53
• NestList[{#, Sqrt[#]}.({#, #^2} & @ RandomVariate[NormalDistribution[]]) &, 1, 10] does the trick if you just want a list of numbers. Nov 18, 2015 at 17:22
• @LLlAMnYP Thanks, but the RecurrenceTable solution below is more intuitive and, therefore, easier to implement. Nov 23, 2015 at 9:52

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}, {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}} *)


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]]