# Monte Carlo Simulations

In this section we document data structures and methods for Monte Carlo simulation.

## Simulation Types

DiffFusion.SimulationType
struct Simulation
model::Model
times::AbstractVector
X::AbstractArray
dZ::Union{AbstractArray, Nothing}
end

A Simulation object represents the result of a Monte Carlo simulation.

Elements are:

• model - the model used for simulation.
• times - vector of simulation times starting with 0.
• X - tensor of size (N_1, N_2, N_3) and type ModelValue where
• N_1 is length(m.state_alias),
• N_2 is number of Monte Carlo paths,
• N_3 is length(times).
• dZ - Brownian motion increments.
DiffFusion.pseudo_brownian_incrementsFunction
pseudo_brownian_increments(
n_states::Int,
n_paths::Int,
n_times::Int,  # without zero
seed::Int = 271828182846,
)

A simple method to generate Brownian motion increments.

DiffFusion.simple_simulationFunction
simple_simulation(
model::Model,
ch::CorrelationHolder,
times::AbstractVector,
n_paths::Int;
with_progress_bar::Bool = true,
brownian_increments::Function = pseudo_brownian_increments,
store_brownian_increments::Bool = false,
)

A simple Monte Carlo simulation method assuming all model components are state-independent.

DiffFusion.diagonal_simulationFunction
diagonal_simulation(
model::Model,
ch::CorrelationHolder,
times::AbstractVector,
n_paths::Int;
with_progress_bar::Bool = true,
brownian_increments::Function = pseudo_brownian_increments,
store_brownian_increments::Bool = false,
)

A Monte Carlo simulation method assuming all model components are diagonal models.