API Reference
- class pygbm.base_gbm.BaseGBM(y0, mu, sigma)[source]
Bases:
objectBase class for Geometric Brownian Motion (GBM) models.
This class stores the common parameters defining a GBM model. It is intended to be subclassed by concrete simulators that implement specific simulation or visualisation methods.
- y0
Initial value Y(0) of the stochastic process.
- Type:
float
- mu
Drift parameter controlling the average exponential growth rate.
- Type:
float
- sigma
Volatility parameter controlling the magnitude of random fluctuations.
- Type:
float
- class pygbm.gbm_simulator.GBMSimulator(y0, mu, sigma)[source]
Bases:
BaseGBMSimulator for Geometric Brownian Motion (GBM).
This class implements a concrete GBM model by extending the BaseGBM base class. It provides methods to simulate a single GBM path over a fixed time horizon and to visualise the resulting trajectory.
- Parameters:
y0 (float) – Initial value Y(0) of the process.
mu (float) – Drift parameter controlling the average growth rate.
sigma (float) – Volatility parameter controlling the strength of random fluctuations.
- plot_path(t_values, y_values, output=None)[source]
Plot a simulated GBM path.
- Parameters:
t_values (array-like) – Time grid returned by simulate_path.
y_values (array-like) – Simulated GBM values returned by simulate_path.
output (str or None, optional) – If provided, the plot is saved to the specified file path. Otherwise, the plot is displayed on screen.
- simulate_path(T, N)[source]
Simulate a single path of the Geometric Brownian Motion.
The simulation is performed by discretising the time interval [0, T] into N equal steps and applying the exact GBM update formula on each step.
- Parameters:
T (float) – Total time horizon of the simulation.
N (int) – Number of discrete time steps.
- Returns:
t_values (numpy.ndarray) – Array of time points with shape (N + 1,).
y_values (list of float) – Simulated GBM values corresponding to each time point.