The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
The futurize package allows you to easily turn sequential code
into parallel code by piping the sequential code to the futurize()
function. Easy!
library(futurize)
plan(multisession)
library(Sim.DiffProc)
# Define 1D SDE model
f <- expression(0)
g <- expression(1)
mod1d <- snssde1d(drift = f, diffusion = g, x0 = 1, M = 10, N = 100)
stat <- function(x, ...) mean(x)
res <- MCM.sde(mod1d, statistic = stat, R = 10, time = 0.5) |> futurize()
This vignette demonstrates how to use this approach to parallelize
Sim.DiffProc functions such as MCM.sde().
The Sim.DiffProc package provides a comprehensive framework for numerical simulation and inference of Stochastic Differential Equations (SDEs) in R. Because Monte Carlo simulation is highly iterative, running multiple replications in parallel can significantly reduce execution times.
The MCM.sde() function performs Monte Carlo simulations for SDEs.
For example:
library(Sim.DiffProc)
f <- expression(0)
g <- expression(1)
mod1d <- snssde1d(drift = f, diffusion = g, x0 = 1, M = 10, N = 100)
stat <- function(x, ...) mean(x)
res <- MCM.sde(mod1d, statistic = stat, R = 10, time = 0.5)
Here MCM.sde() evaluates sequentially. To run in parallel,
pipe to futurize():
library(futurize)
library(Sim.DiffProc)
res <- MCM.sde(mod1d, statistic = stat, R = 10, time = 0.5) |> futurize()
This will distribute the Monte Carlo replications across the available parallel workers, given that we have set up parallel workers, e.g.
plan(multisession)
The built-in multisession backend parallelizes on your local
computer and works on all operating systems. There are other parallel
backends to choose from, including alternatives to parallelize
locally as well as distributed across remote machines, e.g.
plan(future.mirai::mirai_multisession)
and
plan(future.batchtools::batchtools_slurm)
The following Sim.DiffProc functions are supported by futurize():
MCM.sde() with seed = TRUE as the defaultThese binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.