File Exchange

image thumbnail


version (87.5 KB) by Andrew Horchler
Matlab Toolbox for the Numerical Solution of Stochastic Differential Equations (SDEs)


Updated 30 Sep 2020

From GitHub

View license on GitHub

Matlab Toolbox for the Numerical Solution of Stochastic Differential Equations

Cite As

Andrew Horchler (2021). SDETools (, GitHub. Retrieved .

Comments and Ratings (6)

Madhav Ramesh

How can I show "almost sure" convergence for a solution trajectory? I guess that convergence in probability is easy to show: For the probability of the 2-norm of a solution x(t) to be greater than a specified quantity we can upper-bound it by its expected value.

Andrew Horchler

@DemetriPananos: See my answer on Github:

Demetri Pananos

Is there a way to constrain the solution between 0 and 1?

Andrew Horchler

@Roman: Thanks. I can't replicate your issue on R2015b. What version of Matlab are you using? What OS? And was that the full error message (line 44 of sde_gbm is in the help)?

Feel free to file an issue on Github or contact me directly from there:


Interesting set of functions. Trying to simulate a standard GBM for market type stochastics results in an out-of-memory error message.

Trying to run the example in sde_gbm.m in the following way:

>> npaths = 10; dt = 1e-2; t = 0:dt:10; y0 = ones(npaths,1);
% mu = 0.1; sig = (0.1:0.1:0.1*npaths)';
mu = 0.1; sig = [0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2]';
opts = sdeset('RandSeed',1,'SDEType','Ito');
y1 = sde_gbm(mu,sig,t,y0,opts);
y2 = sde_euler(@(t,y)mu*y,@(t,y)sig.*y,t,y0,opts);
figure; h = plot(t,y1,'b',t,y2,'r'); xlabel('t'); ylabel('y(t)');
mustr = num2str(mu); npstr = num2str(npaths); dtstr = num2str(dt);
txt = {'Analytical solution',['Numerical solution, dt = ' dtstr]};
legend(h([1 end]),txt,2); legend boxoff;
title(['Geometric Brownian motion, ' npstr ' paths, \mu = ' mustr]);
Out of memory. The likely cause is an infinite recursion within the program.

Error in sde_gbm (line 44)
y1 = sde_gbm(mu,sig,t,y0,opts);

MATLAB Release Compatibility
Created with R2015a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!