statistic
statistic
Store the simulations of an estimator (underlying, payoff) and add tools to describe its statistics: moments, density, etc.
- class NoStatistic[source]
Bases:
objectNoStatistic object: statistics for this variable are not needed
- class Density(label: str, process_representation: ProcessRepresentation)[source]
Bases:
objectDefine and plot the density function of a stochastic underlying modelled by a Lévy model
- __init__(label: str, process_representation: ProcessRepresentation)[source]
- Parameters
label – label of the density plot
process_representation – how the process is represented by the model (identity or log)
- class Statistic(label: str, shape: tuple, mc_paths: int, process_representation: ProcessRepresentation)[source]
Bases:
objectStatistics object to manage the simulated variables and handle requests such as plotting their density
- __init__(label: str, shape: tuple, mc_paths: int, process_representation: ProcessRepresentation)[source]
- Parameters
label – label of the simulated variables
shape – shape of the input data
mc_paths – number of simulations in the Monte-Carlo engine
- class MCStatistics(*, payoff_statistics: ~rpylib.montecarlo.statistic.statistic.Statistic, spot_underlying_statistics: ~rpylib.montecarlo.statistic.statistic.Statistic =, control_variates_statistics: ~rpylib.montecarlo.statistic.statistic.Statistic =)[source]
Bases:
objectStatistics object when used with a standard Monte-Carlo engine
- __init__(*, payoff_statistics: ~rpylib.montecarlo.statistic.statistic.Statistic, spot_underlying_statistics: ~rpylib.montecarlo.statistic.statistic.Statistic =, control_variates_statistics: ~rpylib.montecarlo.statistic.statistic.Statistic =)[source]
- Parameters
payoff_statistics – statistics object handling the simulations of the payoff
spot_underlying_statistics – statistics object handling the simulations of the spot underlying
control_variates_statistics – statistics object handling the simulations of the control variates
- class MLMCResults(Nl: array, sum_cost: array, all_pl_fine: list, all_pl_coarse: list)[source]
Bases:
objectHandle the output of the Multilevel Monte-Carlo
- __init__(Nl: array, sum_cost: array, all_pl_fine: list, all_pl_coarse: list)[source]
- Parameters
Nl – number of Monte-Carlo paths for each level l
sum_cost – array of the cost for each level l
all_pl_fine – correction terms for the fine payoff for each level l
all_pl_coarse – correction terms for the coarse payoff for each level l
- property mean_level_l
- property var_level_l
- property kurtosis
- property ml
Mean of the correction terms \(|P_l - P_{l-1}|\) for the level l
- property vl
Variance of the correction terms \(|P_l - P_{l-1}|\) for the level l
- property cl
Algorithm cost associated to the level l
- property cost
total cost of the Multilevel Monte-Carlo algorithm
- property consistency_check
- class MLMCStatistics(mc_statistics: list[rpylib.montecarlo.statistic.statistic.MCStatistics], create_statistic)[source]
Bases:
objectStatistics object when used with a Multilevel Monte-Carlo engine
- __init__(mc_statistics: list[rpylib.montecarlo.statistic.statistic.MCStatistics], create_statistic)[source]
- Parameters
mc_statistics – list of the statistics object for each level l
create_statistic – helper function to create individual statistics
- create_mc_statistics(mc_paths: int, underlying_density: [collections.abc.Callable[[float], float]], control_variates: ControlVariates, payoff_dimension: int, process_representation: ProcessRepresentation, activate_spot_statistics: bool, spot_dimension: int) MCStatistics[source]
Factory method which returns the MCStatistics object
- Parameters
mc_paths – number of Monte-Carlo paths
underlying_density – theoretical underlying density
control_variates – control variates object
payoff_dimension – dimension of the payoff (that is the number of underlyings passed to the payoff function)
process_representation – process representation in the model
activate_spot_statistics – if True, compute and save the simulated values of the modelled underlying process
spot_dimension – dimension of the modelled underlying process
- create_mlmc_statistics(mc_paths: int, underlying_density: [collections.abc.Callable[[float], float]], initial_level: int, control_variates: ControlVariates, payoff_dimension: int, process_representation: ProcessRepresentation) MLMCStatistics[source]
Factory method which returns the MLMCStatistics object
- Parameters
mc_paths – number of Monte-Carlo paths
underlying_density – theoretical underlying density
initial_level – initial number of levels
control_variates – control variates object
payoff_dimension – dimension of the payoff (that is the number of underlyings passed to the payoff function)
process_representation – process representation in the model
tools
Useful tool for computing statistics
- class NonCenteredMoments(simulations: list[numpy.array])[source]
Bases:
objectComputation of the moments E[X^k] of X
- __init__(simulations: list[numpy.array])[source]
- Parameters
simulations – list of ndarray, each element corresponds to the simulations of the level l of
the Multilevel Monte-Carlo (only one element for a standard Monte-Carlo engine)
- property ncm_first
- Returns
first non-centered moment, ie E[X]
- property ncm_second
- Returns
second non-centered moment, ie E[X^2]
- property ncm_third
- Returns
third non-centered moment, ie E[X^3]
- property ncm_fourth
- Returns
fourth non-centered moment, ie E[X^4]