Implementation:Avhz RustQuant GeometricBrownianMotion new
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Stochastic_Processes, Monte_Carlo |
| Last Updated | 2026-02-07 20:00 GMT |
Overview
Concrete tool for instantiating a Geometric Brownian Motion stochastic process provided by the RustQuant stochastics crate.
Description
The GeometricBrownianMotion struct implements the StochasticProcess trait with drift = mu * x and diffusion = sigma * x. Parameters can be either constant f64 values or time-dependent closures via the ModelParameter type. The process has no jump component.
Usage
Import this struct when you need to simulate asset price paths for Monte Carlo pricing or when modeling equity/index dynamics. Combine with StochasticProcessConfig and call generate() to produce sample paths.
Code Reference
Source Location
- Repository: RustQuant
- File: crates/RustQuant_stochastics/src/geometric_brownian_motion.rs
- Lines: L14-63
Signature
pub struct GeometricBrownianMotion {
pub mu: ModelParameter,
pub sigma: ModelParameter,
}
impl GeometricBrownianMotion {
pub fn new(mu: impl Into<ModelParameter>, sigma: impl Into<ModelParameter>) -> Self
pub fn parameters(&self) -> Vec<f64>
pub fn unpack(&self) -> (f64, f64)
}
impl StochasticProcess for GeometricBrownianMotion {
fn drift(&self, x: f64, t: f64) -> f64 // mu(t) * x
fn diffusion(&self, x: f64, t: f64) -> f64 // sigma(t) * x
fn jump(&self, _x: f64, _t: f64) -> Option<f64> // None
}
Import
use RustQuant::stochastics::GeometricBrownianMotion;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| mu | impl Into<ModelParameter> | Yes | Drift parameter (f64 or Fn(f64)->f64) |
| sigma | impl Into<ModelParameter> | Yes | Volatility parameter (f64 or Fn(f64)->f64) |
Outputs
| Name | Type | Description |
|---|---|---|
| return | GeometricBrownianMotion | A process implementing StochasticProcess trait, ready for path generation |
Usage Examples
Constant Parameters
use RustQuant::stochastics::{
GeometricBrownianMotion, StochasticProcess,
StochasticProcessConfig, StochasticScheme,
};
// Create GBM with constant drift=5% and vol=20%
let gbm = GeometricBrownianMotion::new(0.05, 0.20);
// Configure simulation
let config = StochasticProcessConfig::new(
100.0, // initial price
0.0, // start time
1.0, // end time (1 year)
252, // daily steps
StochasticScheme::EulerMaruyama,
10_000, // number of paths
true, // parallel execution
None, // no seed (random)
);
// Generate paths
let trajectories = gbm.generate(&config);
println!("Generated {} paths", trajectories.paths.len());
For Monte Carlo Pricing
use RustQuant::stochastics::GeometricBrownianMotion;
// For risk-neutral MC pricing, use risk-free rate as drift
let interest_rate = 0.05;
let volatility = 0.20;
let process = GeometricBrownianMotion::new(interest_rate, volatility);
Related Pages
Implements Principle
Requires Environment
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment