module

Stochasta::MonteCarlo

Class methods

integrate(a : Float64, b : Float64, samples : Int32 = 100000, &) : Float64

Performs 1D Monte Carlo integration of a function f over [a, b]

Source
integrate_multi(bounds : Array(Tuple(Float64, Float64)), samples : Int32 = 100000, &) : Float64

Performs Multi-dimensional Monte Carlo integration of a function f over the bounding boxes defined by bounds (array of {min, max} tuples)

Source
simulate(n : Int32, &) : Array(T) forall T

Runs a stochastic simulation N times and returns the results. Yields the run index to the block, which should return the outcome.

Source