Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
randomvariablelsmbasissystem.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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
20
21#include <ql/time/date.hpp>
22
23#include <boost/test/unit_test.hpp>
24
25using namespace QuantExt;
26
27BOOST_AUTO_TEST_SUITE(QuantExtTestSuite)
28
29BOOST_AUTO_TEST_SUITE(RandomVariableLsmBasisSystemTest)
30
31BOOST_AUTO_TEST_CASE(testBasisSystem1d) {
32
33 BOOST_TEST_MESSAGE("Testing lsm basis system for random variables...");
34
35 constexpr double x0 = -2.0;
36 for (Size order = 0; order < 200; ++order) {
37 auto bs =
38 RandomVariableLsmBasisSystem::pathBasisSystem(order, QuantLib::LsmBasisSystem::PolynomialType::Monomial);
39 BOOST_REQUIRE(bs.size() == order + 1);
40 for (Size i = 0; i <= order; ++i) {
41 BOOST_CHECK_CLOSE(bs[i](RandomVariable(1, x0)).at(0), std::pow(x0, i), 1E-10);
42 }
43 }
44}
45
46BOOST_AUTO_TEST_SUITE_END()
47
48BOOST_AUTO_TEST_SUITE_END()
static std::vector< std::function< RandomVariable(const RandomVariable &)> > pathBasisSystem(Size order, QuantLib::LsmBasisSystem::PolynomialType type)
ql utility class for random variables
BOOST_AUTO_TEST_CASE(testBasisSystem1d)