QuantLib
: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ql
math
statistics
discrepancystatistics.cpp
Go to the documentation of this file.
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
Copyright (C) 2003 Ferdinando Ametrano
5
6
This file is part of QuantLib, a free-software/open-source library
7
for financial quantitative analysts and developers - http://quantlib.org/
8
9
QuantLib is free software: you can redistribute it and/or modify it
10
under the terms of the QuantLib license. You should have received a
11
copy of the license along with this program; if not, please email
12
<quantlib-dev@lists.sf.net>. The license is also available online at
13
<http://quantlib.org/license.shtml>.
14
15
This program is distributed in the hope that it will be useful, but WITHOUT
16
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17
FOR A PARTICULAR PURPOSE. See the license for more details.
18
*/
19
20
#include <
ql/math/statistics/discrepancystatistics.hpp
>
21
22
namespace
QuantLib
{
23
24
Real
DiscrepancyStatistics::discrepancy
()
const
{
25
Size
N =
samples
();
26
/*
27
Size i;
28
Real r_ik, r_jk, cdiscr = adiscr = 0.0, temp = 1.0;
29
30
for (i=0; i<N; i++) {
31
Real temp = 1.0;
32
for (Size k=0; k<dimension_; k++) {
33
r_ik = stats_[k].sampleData()[i].first;
34
temp *= (1.0 - r_ik*r_ik);
35
}
36
cdiscr += temp;
37
}
38
39
for (i=0; i<N; i++) {
40
for (Size j=0; j<N; j++) {
41
Real temp = 1.0;
42
for (Size k=0; k<dimension_; k++) {
43
r_jk = stats_[k].sampleData()[j].first;
44
r_ik = stats_[k].sampleData()[i].first;
45
temp *= (1.0 - std::max(r_ik, r_jk));
46
}
47
adiscr += temp;
48
}
49
}
50
*/
51
return
std::sqrt(
adiscr_
/(N*N)-
bdiscr_
/N*
cdiscr_
+
ddiscr_
);
52
}
53
54
}
55
56
QuantLib::DiscrepancyStatistics::adiscr_
Real adiscr_
Definition:
discrepancystatistics.hpp:96
QuantLib::DiscrepancyStatistics::bdiscr_
Real bdiscr_
Definition:
discrepancystatistics.hpp:97
QuantLib::DiscrepancyStatistics::cdiscr_
Real cdiscr_
Definition:
discrepancystatistics.hpp:96
QuantLib::DiscrepancyStatistics::discrepancy
Real discrepancy() const
Definition:
discrepancystatistics.cpp:24
QuantLib::DiscrepancyStatistics::ddiscr_
Real ddiscr_
Definition:
discrepancystatistics.hpp:97
QuantLib::GenericSequenceStatistics::samples
Size samples() const
Definition:
sequencestatistics.hpp:165
discrepancystatistics.hpp
Statistic tool for sequences with discrepancy calculation.
QuantLib::Real
QL_REAL Real
real number
Definition:
types.hpp:50
QuantLib::Size
std::size_t Size
size of a container
Definition:
types.hpp:58
QuantLib
Definition:
any.hpp:35
Generated by
Doxygen
1.9.5