How to make a random function $\eta(t)$ to insert in a differential equation for NDSolve?

Edit: example: to solve equations like $\frac{dx}{dt}=\eta(t)$

  • 1
    $\begingroup$ The numerical methods used by NDSolve won't work correctly if you introduce noise. $\endgroup$ – Szabolcs May 14 '13 at 19:23
  • 2
    $\begingroup$ But do take a look here: reference.wolfram.com/mathematica/guide/… $\endgroup$ – Szabolcs May 14 '13 at 19:24
  • 2
    $\begingroup$ @richard Please still consider adding a minimal example so that someone can perhaps provide an answer using the new stochastic process functions in version 9 (or you can answer your own question as well). That way, it will also be of use to future visitors who have the same problem (I had forgotten as well and was reminded of the new functionality by Szabolcs's link) $\endgroup$ – rm -rf May 14 '13 at 19:38
  • 1
    $\begingroup$ As you've seen, you should have mentioned you're dealing with SDEs at the outset. NDSolve[] indeed does not have SDE-solving capability, but the new functions in 9 will be useful. $\endgroup$ – J. M. will be back soon May 15 '13 at 4:15
  • 1
    $\begingroup$ Well, it certainly wasn't intended to be used for SDEs. It was, for instance, only relatively recently that NDSolve[] started supporting DAEs and DDEs; maybe a future version might add SDE support, but not now. Thus, you might need to roll your own solution. If you can't or won't use version 9, you may have to implement the Itō process on your own. $\endgroup$ – J. M. will be back soon May 15 '13 at 4:30

I think what he means is the following (I could be wrong though). In Mathematica white noise is represented by WienerProcess "also known as Brownian motion, a continuous-time random walk, or integrated white Gaussian noise." ~ Documentation. So adopting (actually simplifying) this example we get the following:

\[ScriptCapitalP] = 
 ItoProcess[\[DifferentialD]x[t] == σ \[DifferentialD]w[t], 
  x[t], {x, x0}, t, w \[Distributed] WienerProcess[]]
 ItoProcess[{{0}, {{σ}}, x[t]}, {{x}, {x0}}, {t, 0}]

Simulate the process for different values of the variance parameter:

  RandomFunction[\[ScriptCapitalP] /. {x0 -> 5}, {0, 4, 0.01}, 10], 
  PlotLabel -> 
   Row[{"σ", "\[Equal]", N@σ}]], {σ, {1/4, 1/2, 
   1, 2}}]

enter image description here

You can find many characteristics now - see details on the page a linked above, but here is a taste - find the probability density function of the value of the process:

PDF[\[ScriptCapitalP][t], x]
 E^(-((x - x0)^2/(2 t σ^2)))/(Sqrt[2 π] Sqrt[t σ^2])
  • 1
    $\begingroup$ Nice, I think this is exactly what the OP was after. Perhaps you could also give this question a shot... $\endgroup$ – rm -rf May 14 '13 at 20:54
  • $\begingroup$ I don't have version 9 $\endgroup$ – richard May 14 '13 at 21:03
  • $\begingroup$ @rm-rf thanks, i will take a look when I get time. That looks like an interesting equation. $\endgroup$ – Vitaliy Kaurov May 14 '13 at 21:30
  • $\begingroup$ @richard maybe you could try a free trial version for now - just to see how it works. $\endgroup$ – Vitaliy Kaurov May 14 '13 at 21:30
  • $\begingroup$ +1 for solving the OP's problem partially, though white noise is not necessarily Gaussian. $\endgroup$ – Silvia May 15 '13 at 12:07

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.