ntraj=10;
getf("euler1d.sci");
// Diffusion de Black et Scholes
deff("y=mu0(t,x)","y=0");
deff("y=sigma0(t,x)","y=x");
traj=euler1d(mu0,sigma0,1,0.001,1000,10);
xset("window",0); xbasc();
plotframe([0,0,1,10],[10,1,10,1],[%f,%f],..
["Diffusion de Black et Scholes","",""]);  // preparation du cadre graphique
t=[0:0.001:1]'*ones(1,ntraj);                // matrice des abscisses
plot2d(t,traj,ones(1,ntraj),"000");        // representation des trajectoires
//
// Diffusion de Black et Scholes avec derive
//
deff("y=mu1(t,x)","y=x");
deff("y=sigma1(t,x)","y=x");
xset("window",1); xbasc();
traj=euler1d(mu1,sigma1,1,0.01,1000,10);
tmin = 0; tmax = 10;
xmin = min(traj); xmax = max(traj);
xset("window",1); xbasc();
plotframe([tmin,xmin,tmax,xmax],[10,1,10,1],[%f,%f],..
["Black et Scholes avec derive","",""]);   // preparation du cadre graphique
t=[0:0.01:10]'*ones(1,ntraj);                // matrice des abscisses
plot2d(t,traj,ones(1,ntraj),"000");        // representation des trajectoires
//
// Processus d'Ornstein-Uhlenbeck
//
deff("y=mu2(t,x)","y=-x");
deff("y=sigma2(t,x)","y=1");
traj=euler1d(mu2,sigma2,10,0.01,300,10);
tmin = 0; tmax = 3;
xmin = min(traj); xmax = max(traj);
xset("window",2); xbasc();
plotframe([tmin,xmin,tmax,xmax],[10,1,10,1],[%f,%f],..
["Ornstein-Uhlenbeck","",""]);   // preparation du cadre graphique
t=[0:0.01:tmax]'*ones(1,ntraj);                // matrice des abscisses
plot2d(t,traj,ones(1,ntraj),"000");        // representation des trajectoires
//
// Solution de DX=sin(t) dt + X dW
//
deff("y=mu3(t,x)","y=sin(t)");
deff("y=sigma3(t,x)","y=x");
traj=euler1d(mu3,sigma3,0,0.01,2000,10);
tmin = 0; tmax = 20;
xmin = min(traj); xmax = max(traj);
xset("window",3); xbasc();
plotframe([tmin,xmin,tmax,xmax],[10,1,10,1],[%f,%f],..
["dX = sint(t) dt + X dW","",""]);         // preparation du cadre graphique
t=[0:0.01:tmax]'*ones(1,ntraj);              // matrice des abscisses
plot2d(t,traj,ones(1,ntraj),"000");        // representation des trajectoires

//
// Diffusion de Fisher et Wright
//
deff("y=mu4(t,x)","y=0");
deff("y=sigma4(t,x)","y=sqrt(abs(x.*(1-x)))");
traj=euler1d(mu4,sigma4,0.5,0.001,1000,10);
tmin = 0; tmax = 1;
xmin = min(traj); xmax = max(traj);
xset("window",4); xbasc();
plotframe([tmin,xmin,tmax,xmax],[10,1,10,1],[%f,%f],..
["diffusion de Fisher et Wright","",""]);   // preparation du cadre graphique
t=[0:0.001:1]'*ones(1,ntraj);               // matrice des abscisses
plot2d(t,traj,ones(1,ntraj),"000");         // representation des trajectoires































