QuantLib: a free/open-source library for quantitative finance
Reference manual - version 1.40
Loading...
Searching...
No Matches
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 >:

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

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

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.