def gbm(n_years=10, n_scenarios=1000, mu=0.07, sigma=0.15, steps_per_year=12, s_0=100.0, prices=True):
    '\n    Evolution of Geometric Brownian Motion trajectories, such as for Stock Prices through Monte Carlo\n    :param n_years:  The number of years to generate data for\n    :param n_paths: The number of scenarios/trajectories\n    :param mu: Annualized Drift, e.g. Market Return\n    :param sigma: Annualized Volatility\n    :param steps_per_year: granularity of the simulation\n    :param s_0: initial value\n    :return: a numpy array of n_paths columns and n_years*steps_per_year rows\n    '
    dt = (1 / steps_per_year)
    n_steps = (int((n_years * steps_per_year)) + 1)
    rets_plus_1 = np.random.normal(loc=((1 + mu) ** dt), scale=(sigma * np.sqrt(dt)), size=(n_steps, n_scenarios))
    rets_plus_1[0] = 1
    ret_val = ((s_0 * pd.DataFrame(rets_plus_1).cumprod()) if prices else (rets_plus_1 - 1))
    return ret_val
Evolution of Geometric Brownian Motion trajectories, such as for Stock Prices through Monte Carlo
:param n_years:  The number of years to generate data for
:param n_paths: The number of scenarios/trajectories
:param mu: Annualized Drift, e.g. Market Return
:param sigma: Annualized Volatility
:param steps_per_year: granularity of the simulation
:param s_0: initial value
:return: a numpy array of n_paths columns and n_years*steps_per_year rows
def gbm(n_years=10, n_scenarios=1000, mu=0.07, sigma=0.15, steps_per_year=12, s_0=100.0, prices=True):
    '\n    Evolution of Geometric Brownian Motion trajectories, such as for Stock Prices through Monte Carlo\n    :param n_years:  The number of years to generate data for\n    :param n_paths: The number of scenarios/trajectories\n    :param mu: Annualized Drift, e.g. Market Return\n    :param sigma: Annualized Volatility\n    :param steps_per_year: granularity of the simulation\n    :param s_0: initial value\n    :return: a numpy array of n_paths columns and n_years*steps_per_year rows\n    '
    dt = (1 / steps_per_year)
    n_steps = (int((n_years * steps_per_year)) + 1)
    rets_plus_1 = np.random.normal(loc=((1 + mu) ** dt), scale=(sigma * np.sqrt(dt)), size=(n_steps, n_scenarios))
    rets_plus_1[0] = 1
    ret_val = ((s_0 * pd.DataFrame(rets_plus_1).cumprod()) if prices else (rets_plus_1 - 1))
    return ret_val