R Under development (unstable) (2025-12-12 r89163 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(Sim.DiffProc) > > ## 2-dim SDE > set.seed(1234) > > # SDE's 2d > fx <- expression(3*(2-y),2*x) > gx <- expression(1,y) > mod2d <- snssde2d(drift=fx,diffusion=gx,x0=c(1,2),M=1000) > > # random > r2d <- rsde2d(mod2d,at=0.5) > summary(r2d) x y Min. :-5.6639 Min. : 0.4349 1st Qu.:-0.3902 1st Qu.: 1.7160 Median : 0.5497 Median : 2.4000 Mean : 0.3265 Mean : 2.7618 3rd Qu.: 1.2958 3rd Qu.: 3.3156 Max. : 3.3886 Max. :12.1161 > > # Marginal density > > denM <- dsde2d(mod2d,pdf="M", at=0.5) > denM Marginal density of X(t-t0)|X(t0)=1 at time t = 0.5 Data: x (1000 obs.); Bandwidth 'bw' = 0.2844 x f(x) Min. :-6.517219 Min. :0.00002345 1st Qu.:-3.827439 1st Qu.:0.00869079 Median :-1.137660 Median :0.02711701 Mean :-1.137660 Mean :0.09276253 3rd Qu.: 1.552120 3rd Qu.:0.16197889 Max. : 4.241899 Max. :0.33562892 Marginal density of Y(t-t0)|Y(t0)=2 at time t = 0.5 Data: y (1000 obs.); Bandwidth 'bw' = 0.2699 y f(y) Min. :-0.3746588 Min. :0.00001694 1st Qu.: 2.9504288 1st Qu.:0.00286031 Median : 6.2755165 Median :0.01451506 Mean : 6.2755165 Mean :0.07503885 3rd Qu.: 9.6006042 3rd Qu.:0.09181273 Max. :12.9256919 Max. :0.37303833 > plot(denM) > > # Joint density > denJ <- dsde2d(mod2d,pdf="J", at= 0.5) > denJ Joint density of (X(t-t0),Y(t-t0)|X(t0)=1,Y(t0)=2) at time t = 0.5 Data: (x,y) (2 x 1000 obs.); x y f(x,y) Min. :-5.663883 Min. : 0.4349363 Min. :0.000000000 1st Qu.:-3.400771 1st Qu.: 3.3552264 1st Qu.:0.000009329 Median :-1.137660 Median : 6.2755165 Median :0.000797373 Mean :-1.137660 Mean : 6.2755165 Mean :0.008690271 3rd Qu.: 1.125452 3rd Qu.: 9.1958067 3rd Qu.:0.004050708 Max. : 3.388564 Max. :12.1160968 Max. :0.148301896 > plot(denJ) > plot(denJ,display="contour") > > proc.time() user system elapsed 0.70 0.12 0.81