Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef OPENMS_MATH_STATISTICS_GAMMADISTRIBUTIONFITTER_H
00036 #define OPENMS_MATH_STATISTICS_GAMMADISTRIBUTIONFITTER_H
00037
00038 #include <OpenMS/DATASTRUCTURES/String.h>
00039 #include <OpenMS/DATASTRUCTURES/DPosition.h>
00040
00041 #include <vector>
00042
00043
00044 #include <gsl/gsl_rng.h>
00045 #include <gsl/gsl_vector.h>
00046 #include <gsl/gsl_multifit_nlin.h>
00047
00048
00049 namespace OpenMS
00050 {
00051 namespace Math
00052 {
00067 class OPENMS_DLLAPI GammaDistributionFitter
00068 {
00069 public:
00070
00072 struct GammaDistributionFitResult
00073 {
00074 public:
00075
00076 GammaDistributionFitResult() :
00077 b(1.0),
00078 p(5.0)
00079 {
00080 }
00081
00082 GammaDistributionFitResult(const GammaDistributionFitResult & rhs) :
00083 b(rhs.b),
00084 p(rhs.p)
00085 {
00086 }
00087
00088 GammaDistributionFitResult & operator=(const GammaDistributionFitResult & rhs)
00089 {
00090 if (this != &rhs)
00091 {
00092 b = rhs.b;
00093 p = rhs.p;
00094 }
00095 return *this;
00096 }
00097
00099 double b;
00100
00102 double p;
00103 };
00104
00106 GammaDistributionFitter();
00108 virtual ~GammaDistributionFitter();
00109
00111 void setInitialParameters(const GammaDistributionFitResult & result);
00112
00120 GammaDistributionFitResult fit(std::vector<DPosition<2> > & points);
00121
00123 const String & getGnuplotFormula() const;
00124
00125 protected:
00126
00127 static int gammaDistributionFitterf_(const gsl_vector * x, void * params, gsl_vector * f);
00128
00129 static int gammaDistributionFitterdf_(const gsl_vector * x, void * params, gsl_matrix * J);
00130
00131 static int gammaDistributionFitterfdf_(const gsl_vector * x, void * params, gsl_vector * f, gsl_matrix * J);
00132
00133 void printState_(size_t iter, gsl_multifit_fdfsolver * s);
00134
00135 GammaDistributionFitResult init_param_;
00136
00137 String gnuplot_formula_;
00138
00139 private:
00141 GammaDistributionFitter(const GammaDistributionFitter & rhs);
00143 GammaDistributionFitter & operator=(const GammaDistributionFitter & rhs);
00144 };
00145 }
00146 }
00147
00148 #endif