1 // -*- C++ -*- 2 /** 3 * @brief StatTest implements statistical tests 4 * 5 * Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca 6 * 7 * This library is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with this library. If not, see <http://www.gnu.org/licenses/>. 19 * 20 */ 21 #ifndef OPENTURNS_FITTINGTEST_HXX 22 #define OPENTURNS_FITTINGTEST_HXX 23 24 #include "openturns/OTprivate.hxx" 25 #include "openturns/TestResult.hxx" 26 #include "openturns/Collection.hxx" 27 #include "openturns/Sample.hxx" 28 #include "openturns/Distribution.hxx" 29 #include "openturns/DistributionFactory.hxx" 30 #include "openturns/Pointer.hxx" 31 32 BEGIN_NAMESPACE_OPENTURNS 33 34 /** 35 * @class FittingTest 36 * 37 */ 38 39 class OT_API FittingTest 40 { 41 public: 42 43 typedef Collection<DistributionFactory> DistributionFactoryCollection; 44 typedef Collection<Distribution> DistributionCollection; 45 46 /** Best model for a given numerical sample by AIC */ 47 static Distribution BestModelAIC(const Sample &sample, 48 const DistributionFactoryCollection &factoryCollection, 49 Scalar &bestAICOut); 50 51 /** Best model for a given numerical sample by AIC */ 52 static Distribution BestModelAIC(const Sample &sample, 53 const DistributionCollection &distributionCollection, 54 Scalar &bestAICOut); 55 56 /** Best model for a given numerical sample by AICc */ 57 static Distribution BestModelAICC(const Sample &sample, 58 const DistributionFactoryCollection &factoryCollection, 59 Scalar &bestAICOut); 60 61 /** Best model for a given numerical sample by AICc */ 62 static Distribution BestModelAICC(const Sample &sample, 63 const DistributionCollection &distributionCollection, 64 Scalar &bestAICOut); 65 66 /** Best model for a given numerical sample by BIC */ 67 static Distribution BestModelBIC(const Sample & sample, 68 const DistributionFactoryCollection & factoryCollection, 69 Scalar & bestBICOut); 70 71 /** Best model for a given numerical sample by BIC */ 72 static Distribution BestModelBIC(const Sample & sample, 73 const DistributionCollection & distributionCollection, 74 Scalar & bestBICOut); 75 76 /** Best model for a given numerical sample by Lilliefors */ 77 static Distribution BestModelLilliefors(const Sample & sample, 78 const DistributionFactoryCollection & factoryCollection, 79 TestResult & bestResultOut); 80 81 /** Best model for a given numerical sample by Kolmogorov */ 82 static Distribution BestModelKolmogorov(const Sample & sample, 83 const DistributionCollection & distributionCollection, 84 TestResult & bestResultOut); 85 86 /** Best model for a given numerical sample by ChiSquared */ 87 static Distribution BestModelChiSquared(const Sample & sample, 88 const DistributionFactoryCollection & factoryCollection, 89 TestResult & bestResultOut); 90 91 /** Best model for a given numerical sample by ChiSquared */ 92 static Distribution BestModelChiSquared(const Sample & sample, 93 const DistributionCollection & distributionCollection, 94 TestResult & bestResultOut); 95 96 /** Akaike Information Criterion computation */ 97 static Scalar AIC(const Sample &sample, 98 const Distribution &distribution, 99 const UnsignedInteger estimatedParameters = 0); 100 101 /** Akaike Information Criterion computation */ 102 static Distribution AIC(const Sample &sample, 103 const DistributionFactory &factory, 104 Scalar &bestAICOut); 105 106 /** Akaike Information Criterion corrected (AICc) computation */ 107 static Scalar AICC(const Sample &sample, 108 const Distribution &distribution, 109 const UnsignedInteger estimatedParameters = 0); 110 111 /** Akaike Information Criterion corrected (AICc) computation */ 112 static Distribution AICC(const Sample &sample, 113 const DistributionFactory &factory, 114 Scalar &bestAICOut); 115 116 /** Bayesian Information Criterion computation */ 117 static Scalar BIC(const Sample & sample, 118 const Distribution & distribution, 119 const UnsignedInteger estimatedParameters = 0); 120 121 /** Bayesian Information Criterion computation */ 122 static Distribution BIC(const Sample & sample, 123 const DistributionFactory & factory, 124 Scalar & bestBICOut); 125 126 /** Kolmogorov fitting test for continuous distributions */ 127 static TestResult Kolmogorov(const Sample & sample, 128 const Distribution & distribution, 129 const Scalar level = 0.05); 130 131 /** Lilliefors fitting test for continuous distributions */ 132 static TestResult Lilliefors(const Sample & sample, 133 const DistributionFactory & factory, 134 Distribution & estimatedDistribution, 135 const Scalar level = 0.05); 136 137 /** Kolmogorov statistics computation */ 138 static Scalar ComputeKolmogorovStatistics(const Sample & sample, 139 const Distribution & distribution); 140 141 /** ChiSquared fitting test for discrete distributions */ 142 static TestResult ChiSquared(const Sample & sample, 143 const Distribution & distribution, 144 const Scalar level = 0.05, 145 const UnsignedInteger estimatedParameters = 0); 146 147 /** ChiSquared fitting test for discrete distributions */ 148 static TestResult ChiSquared(const Sample & sample, 149 const DistributionFactory & factory, 150 Distribution & estimatedDistribution, 151 const Scalar level = 0.05); 152 153 private: 154 FittingTest(); 155 156 }; /* class FittingTest */ 157 158 END_NAMESPACE_OPENTURNS 159 #endif /* OPENTURNS_FITTINGTEST_HXX */ 160