1
// -*- mode: C++; tab-width: 2; -*-
4
// --------------------------------------------------------------------------
5
// OpenMS Mass Spectrometry Framework
6
// --------------------------------------------------------------------------
7
// Copyright (C) 2003-2011 -- Oliver Kohlbacher, Knut Reinert
9
// This library is free software; you can redistribute it and/or
10
// modify it under the terms of the GNU Lesser General Public
11
// License as published by the Free Software Foundation; either
12
// version 2.1 of the License, or (at your option) any later version.
14
// This library is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
// Lesser General Public License for more details.
19
// You should have received a copy of the GNU Lesser General Public
20
// License along with this library; if not, write to the Free Software
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
// --------------------------------------------------------------------------
24
// $Maintainer: Andreas Bertsch$
25
// $Authors: Andreas Bertsch $
26
// --------------------------------------------------------------------------
28
#include <OpenMS/CONCEPT/ClassTest.h>
30
///////////////////////////
31
#include <OpenMS/MATH/STATISTICS/GammaDistributionFitter.h>
32
///////////////////////////
34
using namespace OpenMS;
38
START_TEST(GammaDistributionFitter, "$Id: GammaDistributionFitter_test.C 8210 2011-03-28 13:19:52Z aiche $")
40
/////////////////////////////////////////////////////////////
41
/////////////////////////////////////////////////////////////
43
GammaDistributionFitter* ptr = 0;
44
GammaDistributionFitter* nullPointer = 0;
45
START_SECTION(GammaDistributionFitter())
47
ptr = new GammaDistributionFitter();
48
TEST_NOT_EQUAL(ptr, nullPointer)
52
START_SECTION(virtual ~GammaDistributionFitter())
58
START_SECTION((GammaDistributionFitResult fit(std::vector< DPosition< 2 > > & points)))
61
vector<DPosition<2> > points;
63
pos.setX(0.0001); pos.setY(0.1); points.push_back(pos);
64
pos.setX(0.0251); pos.setY(0.3); points.push_back(pos);
65
pos.setX(0.0501); pos.setY(0); points.push_back(pos);
66
pos.setX(0.0751); pos.setY(0.7); points.push_back(pos);
67
pos.setX(0.1001); pos.setY(0); points.push_back(pos);
68
pos.setX(0.1251); pos.setY(1.6); points.push_back(pos);
69
pos.setX(0.1501); pos.setY(0); points.push_back(pos);
70
pos.setX(0.1751); pos.setY(2.1); points.push_back(pos);
71
pos.setX(0.2001); pos.setY(0); points.push_back(pos);
72
pos.setX(0.2251); pos.setY(3.7); points.push_back(pos);
73
pos.setX(0.2501); pos.setY(0); points.push_back(pos);
74
pos.setX(0.2751); pos.setY(4); points.push_back(pos);
75
pos.setX(0.3001); pos.setY(0); points.push_back(pos);
76
pos.setX(0.3251); pos.setY(3); points.push_back(pos);
77
pos.setX(0.3501); pos.setY(0); points.push_back(pos);
78
pos.setX(0.3751); pos.setY(2.6); points.push_back(pos);
79
pos.setX(0.4001); pos.setY(0); points.push_back(pos);
80
pos.setX(0.4251); pos.setY(3); points.push_back(pos);
81
pos.setX(0.4501); pos.setY(0); points.push_back(pos);
82
pos.setX(0.4751); pos.setY(3); points.push_back(pos);
83
pos.setX(0.5001); pos.setY(0); points.push_back(pos);
84
pos.setX(0.5251); pos.setY(2.5); points.push_back(pos);
85
pos.setX(0.5501); pos.setY(0); points.push_back(pos);
86
pos.setX(0.5751); pos.setY(1.7); points.push_back(pos);
87
pos.setX(0.6001); pos.setY(0); points.push_back(pos);
88
pos.setX(0.6251); pos.setY(1); points.push_back(pos);
89
pos.setX(0.6501); pos.setY(0); points.push_back(pos);
90
pos.setX(0.6751); pos.setY(0.5); points.push_back(pos);
91
pos.setX(0.7001); pos.setY(0); points.push_back(pos);
92
pos.setX(0.7251); pos.setY(0.3); points.push_back(pos);
93
pos.setX(0.7501); pos.setY(0); points.push_back(pos);
94
pos.setX(0.7751); pos.setY(0.4); points.push_back(pos);
95
pos.setX(0.8001); pos.setY(0); points.push_back(pos);
96
pos.setX(0.8251); pos.setY(0); points.push_back(pos);
97
pos.setX(0.8501); pos.setY(0); points.push_back(pos);
98
pos.setX(0.8751); pos.setY(0.1); points.push_back(pos);
99
pos.setX(0.9001); pos.setY(0); points.push_back(pos);
100
pos.setX(0.9251); pos.setY(0.1); points.push_back(pos);
101
pos.setX(0.9501); pos.setY(0); points.push_back(pos);
102
pos.setX(0.9751); pos.setY(0.2); points.push_back(pos);
104
GammaDistributionFitter::GammaDistributionFitResult init_param;
108
ptr = new GammaDistributionFitter;
109
ptr->setInitialParameters(init_param);
110
GammaDistributionFitter::GammaDistributionFitResult result = ptr->fit(points);
112
TOLERANCE_ABSOLUTE(0.01)
113
TEST_REAL_SIMILAR(result.b, 7.25)
114
TEST_REAL_SIMILAR(result.p, 3.11)
118
START_SECTION((void setInitialParameters(const GammaDistributionFitResult & result)))
120
GammaDistributionFitter f1;
121
GammaDistributionFitter::GammaDistributionFitResult result;
122
f1.setInitialParameters(result);
124
NOT_TESTABLE //implicitly tested in fit method
128
START_SECTION((const String& getGnuplotFormula() const ))
129
TEST_EQUAL(ptr->getGnuplotFormula().hasPrefix("f(x)="), true)
133
/////////////////////////////////////////////////////////////
134
/////////////////////////////////////////////////////////////