QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Attributes | List of all members
MonteCarloModel< MC, RNG, S > Class Template Reference

General-purpose Monte Carlo model for path samples. More...

#include <ql/methods/montecarlo/montecarlomodel.hpp>

+ Collaboration diagram for MonteCarloModel< MC, RNG, S >:

Public Types

typedef MC< RNG > mc_traits
 
typedef RNG rng_traits
 
typedef MC< RNG >::path_generator_type path_generator_type
 
typedef MC< RNG >::path_pricer_type path_pricer_type
 
typedef path_generator_type::sample_type sample_type
 
typedef path_pricer_type::result_type result_type
 
typedef S stats_type
 

Public Member Functions

 MonteCarloModel (ext::shared_ptr< path_generator_type > pathGenerator, ext::shared_ptr< path_pricer_type > pathPricer, stats_type sampleAccumulator, bool antitheticVariate, ext::shared_ptr< path_pricer_type > cvPathPricer=ext::shared_ptr< path_pricer_type >(), result_type cvOptionValue=result_type(), ext::shared_ptr< path_generator_type > cvPathGenerator=ext::shared_ptr< path_generator_type >())
 
void addSamples (Size samples)
 
const stats_typesampleAccumulator () const
 

Private Attributes

ext::shared_ptr< path_generator_typepathGenerator_
 
ext::shared_ptr< path_pricer_typepathPricer_
 
stats_type sampleAccumulator_
 
bool isAntitheticVariate_
 
ext::shared_ptr< path_pricer_typecvPathPricer_
 
result_type cvOptionValue_
 
bool isControlVariate_
 
ext::shared_ptr< path_generator_typecvPathGenerator_
 

Detailed Description

template<template< class > class MC, class RNG, class S = Statistics>
class QuantLib::MonteCarloModel< MC, RNG, S >

General-purpose Monte Carlo model for path samples.

The template arguments of this class correspond to available policies for the particular model to be instantiated—i.e., whether it is single- or multi-asset, or whether it should use pseudo-random or low-discrepancy numbers for path generation. Such decisions are grouped in trait classes so as to be orthogonal—see mctraits.hpp for examples.

The constructor accepts two safe references, i.e. two smart pointers, one to a path generator and the other to a path pricer. In case of control variate technique the user should provide the additional control option, namely the option path pricer and the option value.

Examples
DiscreteHedging.cpp.

Definition at line 52 of file montecarlomodel.hpp.

Member Typedef Documentation

◆ mc_traits

typedef MC<RNG> mc_traits

Definition at line 54 of file montecarlomodel.hpp.

◆ rng_traits

typedef RNG rng_traits

Definition at line 55 of file montecarlomodel.hpp.

◆ path_generator_type

typedef MC<RNG>::path_generator_type path_generator_type

Definition at line 56 of file montecarlomodel.hpp.

◆ path_pricer_type

typedef MC<RNG>::path_pricer_type path_pricer_type

Definition at line 57 of file montecarlomodel.hpp.

◆ sample_type

typedef path_generator_type::sample_type sample_type

Definition at line 58 of file montecarlomodel.hpp.

◆ result_type

typedef path_pricer_type::result_type result_type

Definition at line 59 of file montecarlomodel.hpp.

◆ stats_type

typedef S stats_type

Definition at line 60 of file montecarlomodel.hpp.

Constructor & Destructor Documentation

◆ MonteCarloModel()

MonteCarloModel ( ext::shared_ptr< path_generator_type pathGenerator,
ext::shared_ptr< path_pricer_type pathPricer,
stats_type  sampleAccumulator,
bool  antitheticVariate,
ext::shared_ptr< path_pricer_type cvPathPricer = ext::shared_ptr<path_pricer_type>(),
result_type  cvOptionValue = result_type(),
ext::shared_ptr< path_generator_type cvPathGenerator = ext::shared_ptr<path_generator_type>() 
)

Definition at line 62 of file montecarlomodel.hpp.

Member Function Documentation

◆ addSamples()

void addSamples ( Size  samples)

Definition at line 92 of file montecarlomodel.hpp.

◆ sampleAccumulator()

const MonteCarloModel< MC, RNG, S >::stats_type & sampleAccumulator

Definition at line 129 of file montecarlomodel.hpp.

Member Data Documentation

◆ pathGenerator_

ext::shared_ptr<path_generator_type> pathGenerator_
private

Definition at line 80 of file montecarlomodel.hpp.

◆ pathPricer_

ext::shared_ptr<path_pricer_type> pathPricer_
private

Definition at line 81 of file montecarlomodel.hpp.

◆ sampleAccumulator_

stats_type sampleAccumulator_
private

Definition at line 82 of file montecarlomodel.hpp.

◆ isAntitheticVariate_

bool isAntitheticVariate_
private

Definition at line 83 of file montecarlomodel.hpp.

◆ cvPathPricer_

ext::shared_ptr<path_pricer_type> cvPathPricer_
private

Definition at line 84 of file montecarlomodel.hpp.

◆ cvOptionValue_

result_type cvOptionValue_
private

Definition at line 85 of file montecarlomodel.hpp.

◆ isControlVariate_

bool isControlVariate_
private

Definition at line 86 of file montecarlomodel.hpp.

◆ cvPathGenerator_

ext::shared_ptr<path_generator_type> cvPathGenerator_
private

Definition at line 87 of file montecarlomodel.hpp.