1

I want to numerically solve a stochastic differential equation (SDE) in MATLAB, The code I have written just simply does not recognize sde function!

The question is as below:

 dz=v*dt +sqrt(2*Ds)*dw_t
 where v = 1/(N*delta) * sigma f_i (i=1- N)
 N= 100,
 delta = e6,

and f_i is calculated form this equation:

 for z>=z0 , f_i = -kappa*(z0_i -z)  and kappa = .17
 for z<z0 ,  f_i = -kappaT*(z0_i -z) and kappaT = 60

note that the initial values for z0_i is randomly distributed over 60nm range.

 Ds = 4e4

and dw_t is an increment in Wiener process.

Firstly I don't know how to set the conditions for z while I don't have the value for it! Secondly, the Euler algorithm is exactly matching the equation but I don't know why the code with sde function is not working!

Roza
  • 21
  • 1
  • 4
  • Can you provide any minimal working example or some actual code? Also what do you mean by not working? which kind of error does it return? In general if you have a complicated SDE you can make a function containing the time increment factor and one which contain the stochastic increment factor and then apply the Euler Maruyama method. – Nicky Mattsson Jun 08 '15 at 11:27
  • 1
    `i=1;` `N=100;` `z0 = 0;` `sf=0;` `k = .17;` `while i – Roza Jun 09 '15 at 15:56
  • You say is does not work, what is the error? Also please edit your original post to include the code, most of use don't like to read an entire code one line. – Nicky Mattsson Jun 09 '15 at 19:37

1 Answers1

0

In order to numerically solve a SDE, you would need a Initial Condition (IC) for the function you want to code. In your case, I guess it's z. If you want to do so without explicitly declaring the IC, you can write it as a function that takes an IC. Then to test, you would input random ICs in.

Also, it is not clear to me whether your z0 is also stochastic and changes with time, is randomly generated every time step, or a constant that was only randomly generated once. Even simpler, if z0 is just the IC of z, then your f_i just inspects whether z has increased or decreased through the time step to decide how z would change the next time step. Please clarify this and your problem will seem much clearer.

It is not too hard to simulate your SDE without the use of the solver. You can try it out and achieve better result since sometimes you will really need to learn the behavior of the solver in order for it to work. I would suggest Monte Carlo method if you choose to write your own solver to ensure accuracy.

I hope my answer helps. If you still have any questions, feel free to ask.

Son Le
  • 21
  • 3