/src/quantlib/ql/math/statistics/discrepancystatistics.cpp
Line | Count | Source |
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 | | <https://www.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 | 0 | Real DiscrepancyStatistics::discrepancy() const { |
25 | 0 | 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 | 0 | return std::sqrt(adiscr_/(N*N)-bdiscr_/N*cdiscr_+ddiscr_); |
52 | 0 | } |
53 | | |
54 | | } |
55 | | |
56 | | |