Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
randomvariable_ops.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2023 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file qle/math/randomvariable_ops.hpp
20 \brief ops for type randomvariable
21*/
22
23#pragma once
24
27
28#include <ql/methods/montecarlo/lsmbasissystem.hpp>
29
30#include <map>
31
32namespace QuantExt {
33
34// random variable operations
35
36using RandomVariableOp = std::function<RandomVariable(const std::vector<const RandomVariable*>&)>;
37
38// eps determines the smoothing, 0 means no smoothing (default)
39std::vector<RandomVariableOp>
40getRandomVariableOps(const Size size, const Size regressionOrder = 2,
41 const QuantLib::LsmBasisSystem::PolynomialType polynomType = QuantLib::LsmBasisSystem::Monomial,
42 const double eps = 0.0, QuantLib::Real regressionVarianceCutoff = Null<Real>());
43
44// random variable gradients
45
47 std::function<std::vector<RandomVariable>(const std::vector<const RandomVariable*>&, const RandomVariable*)>;
48
49// eps determines the smoothing, 0 means no smoothing
50std::vector<RandomVariableGrad> getRandomVariableGradients(
51 const Size size, const Size regressionOrder = 2,
52 const QuantLib::LsmBasisSystem::PolynomialType polynomType = QuantLib::LsmBasisSystem::Monomial,
53 const double eps = 0.2, QuantLib::Real regressionVarianceCutoff = Null<Real>());
54
55// random variable flags which values are needed to compute the gradient
56
57using RandomVariableOpNodeRequirements = std::function<std::pair<std::vector<bool>, bool>(const std::size_t)>;
58std::vector<RandomVariableOpNodeRequirements> getRandomVariableOpNodeRequirements();
59
60} // namespace QuantExt
std::vector< RandomVariableGrad > getRandomVariableGradients(const Size size, const Size regressionOrder, const QuantLib::LsmBasisSystem::PolynomialType polynomType, const double eps, const Real regressionVarianceCutoff)
std::function< std::pair< std::vector< bool >, bool >(const std::size_t)> RandomVariableOpNodeRequirements
std::function< std::vector< RandomVariable >(const std::vector< const RandomVariable * > &, const RandomVariable *)> RandomVariableGrad
std::vector< RandomVariableOpNodeRequirements > getRandomVariableOpNodeRequirements()
std::function< RandomVariable(const std::vector< const RandomVariable * > &)> RandomVariableOp
std::vector< RandomVariableOp > getRandomVariableOps(const Size size, const Size regressionOrder, QuantLib::LsmBasisSystem::PolynomialType polynomType, const double eps, QuantLib::Real regressionVarianceCutoff)