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

base class for Monte Carlo engines More...

#include <ql/pricingengines/mcsimulation.hpp>

+ Inheritance diagram for McSimulation< MC, RNG, S >:
+ Collaboration diagram for McSimulation< MC, RNG, S >:

Public Types

typedef MonteCarloModel< MC, RNG, S >::path_generator_type path_generator_type
 
typedef MonteCarloModel< MC, RNG, S >::path_pricer_type path_pricer_type
 
typedef MonteCarloModel< MC, RNG, S >::stats_type stats_type
 
typedef MonteCarloModel< MC, RNG, S >::result_type result_type
 

Public Member Functions

virtual ~McSimulation ()=default
 
result_type value (Real tolerance, Size maxSamples=QL_MAX_INTEGER, Size minSamples=1023) const
 add samples until the required absolute tolerance is reached More...
 
result_type valueWithSamples (Size samples) const
 simulate a fixed number of samples More...
 
result_type errorEstimate () const
 error estimated using the samples simulated so far More...
 
const stats_typesampleAccumulator () const
 access to the sample accumulator for richer statistics More...
 
void calculate (Real requiredTolerance, Size requiredSamples, Size maxSamples) const
 basic calculate method provided to inherited pricing engines More...
 

Protected Member Functions

 McSimulation (bool antitheticVariate, bool controlVariate)
 
virtual ext::shared_ptr< path_pricer_typepathPricer () const =0
 
virtual ext::shared_ptr< path_generator_typepathGenerator () const =0
 
virtual TimeGrid timeGrid () const =0
 
virtual ext::shared_ptr< path_pricer_typecontrolPathPricer () const
 
virtual ext::shared_ptr< path_generator_typecontrolPathGenerator () const
 
virtual ext::shared_ptr< PricingEnginecontrolPricingEngine () const
 
virtual result_type controlVariateValue () const
 

Static Protected Member Functions

template<class Sequence >
static Real maxError (const Sequence &sequence)
 
static Real maxError (Real error)
 

Protected Attributes

ext::shared_ptr< MonteCarloModel< MC, RNG, S > > mcModel_
 
bool antitheticVariate_
 
bool controlVariate_
 

Detailed Description

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

base class for Monte Carlo engines

Eventually this class might offer greeks methods. Deriving a class from McSimulation gives an easy way to write a Monte Carlo engine.

See McVanillaEngine as an example.

Definition at line 43 of file mcsimulation.hpp.

Member Typedef Documentation

◆ path_generator_type

typedef MonteCarloModel<MC,RNG,S>::path_generator_type path_generator_type

Definition at line 46 of file mcsimulation.hpp.

◆ path_pricer_type

typedef MonteCarloModel<MC,RNG,S>::path_pricer_type path_pricer_type

Definition at line 48 of file mcsimulation.hpp.

◆ stats_type

typedef MonteCarloModel<MC,RNG,S>::stats_type stats_type

Definition at line 50 of file mcsimulation.hpp.

◆ result_type

typedef MonteCarloModel<MC,RNG,S>::result_type result_type

Definition at line 51 of file mcsimulation.hpp.

Constructor & Destructor Documentation

◆ ~McSimulation()

virtual ~McSimulation ( )
virtualdefault

◆ McSimulation()

McSimulation ( bool  antitheticVariate,
bool  controlVariate 
)
protected

Definition at line 69 of file mcsimulation.hpp.

Member Function Documentation

◆ value()

McSimulation< MC, RNG, S >::result_type value ( Real  tolerance,
Size  maxSamples = QL_MAX_INTEGER,
Size  minSamples = 1023 
) const

add samples until the required absolute tolerance is reached

Definition at line 106 of file mcsimulation.hpp.

◆ valueWithSamples()

McSimulation< MC, RNG, S >::result_type valueWithSamples ( Size  samples) const

simulate a fixed number of samples

Definition at line 144 of file mcsimulation.hpp.

◆ errorEstimate()

McSimulation< MC, RNG, S >::result_type errorEstimate

error estimated using the samples simulated so far

Definition at line 211 of file mcsimulation.hpp.

◆ sampleAccumulator()

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

access to the sample accumulator for richer statistics

Definition at line 217 of file mcsimulation.hpp.

◆ calculate()

void calculate ( Real  requiredTolerance,
Size  requiredSamples,
Size  maxSamples 
) const

basic calculate method provided to inherited pricing engines

Definition at line 159 of file mcsimulation.hpp.

+ Here is the caller graph for this function:

◆ pathPricer()

virtual ext::shared_ptr< path_pricer_type > pathPricer ( ) const
protectedpure virtual

◆ pathGenerator()

virtual ext::shared_ptr< path_generator_type > pathGenerator ( ) const
protectedpure virtual

◆ timeGrid()

virtual TimeGrid timeGrid ( ) const
protectedpure virtual

◆ controlPathPricer()

virtual ext::shared_ptr< path_pricer_type > controlPathPricer ( ) const
protectedvirtual

◆ controlPathGenerator()

virtual ext::shared_ptr< path_generator_type > controlPathGenerator ( ) const
protectedvirtual

Reimplemented in MCHestonHullWhiteEngine< RNG, S >.

Definition at line 81 of file mcsimulation.hpp.

◆ controlPricingEngine()

virtual ext::shared_ptr< PricingEngine > controlPricingEngine ( ) const
protectedvirtual

◆ controlVariateValue()

virtual result_type controlVariateValue ( ) const
protectedvirtual

◆ maxError() [1/2]

static Real maxError ( const Sequence &  sequence)
staticprotected

Definition at line 91 of file mcsimulation.hpp.

◆ maxError() [2/2]

static Real maxError ( Real  error)
staticprotected

Definition at line 94 of file mcsimulation.hpp.

Member Data Documentation

◆ mcModel_

ext::shared_ptr<MonteCarloModel<MC,RNG,S> > mcModel_
mutableprotected

Definition at line 98 of file mcsimulation.hpp.

◆ antitheticVariate_

bool antitheticVariate_
protected

Definition at line 99 of file mcsimulation.hpp.

◆ controlVariate_

bool controlVariate_
protected

Definition at line 99 of file mcsimulation.hpp.