5
$\begingroup$

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.

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

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]]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.