OpenMS
GaussFitter.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- EKU Tuebingen, ETH Zurich, and FU Berlin
2 // SPDX-License-Identifier: BSD-3-Clause
3 //
4 // --------------------------------------------------------------------------
5 // $Maintainer: Chris Bielow $
6 // $Authors: Andreas Bertsch, Chris Bielow $
7 // --------------------------------------------------------------------------
8 //
9 
10 #pragma once
11 
15 
16 #include <cmath>
17 #include <vector>
18 
19 namespace OpenMS
20 {
21  namespace Math
22  {
34  class OPENMS_DLLAPI GaussFitter
35  {
36 public:
37 
39  struct OPENMS_DLLAPI GaussFitResult
40  {
41 public:
43  : A(-1.0), x0(-1.0), sigma(-1.0) {}
44  GaussFitResult(double a, double x, double s)
45  : A(a), x0(x), sigma(s) {}
46 
48  double A;
49 
51  double x0;
52 
54  double sigma;
55 
56 
64  double eval(double x) const;
65 
73  double log_eval_no_normalize(double x) const;
74 
75  private:
76  double halflogtwopi = 0.5*log(2.0*Constants::PI);
77  };
78 
81 
83  virtual ~GaussFitter();
84 
86  void setInitialParameters(const GaussFitResult& result);
87 
95  GaussFitResult fit(std::vector<DPosition<2> > & points) const;
96 
105  static std::vector<double> eval(const std::vector<double>& evaluation_points, const GaussFitResult& model);
106 
107 protected:
108 
110 
111 private:
113  GaussFitter(const GaussFitter & rhs);
114 
117  };
118  }
119 }
120 
Implements a fitter for Gaussian functions.
Definition: GaussFitter.h:35
void setInitialParameters(const GaussFitResult &result)
sets the initial parameters used by the fit method as initial guess for the Gaussian
GaussFitter & operator=(const GaussFitter &rhs)
Assignment operator (not implemented)
virtual ~GaussFitter()
Destructor.
static std::vector< double > eval(const std::vector< double > &evaluation_points, const GaussFitResult &model)
Evaluate the current Gaussian model at the specified points.
GaussFitResult fit(std::vector< DPosition< 2 > > &points) const
Fits a Gaussian distribution to the given data points.
GaussFitter(const GaussFitter &rhs)
Copy constructor (not implemented)
GaussFitResult init_param_
Definition: GaussFitter.h:109
const double PI
PI.
Definition: Constants.h:49
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19
struct of parameters of a Gaussian distribution
Definition: GaussFitter.h:40
double log_eval_no_normalize(double x) const
Evaluate the current log density of the Gaussian model at the specified point.
double A
parameter A of Gaussian distribution (amplitude)
Definition: GaussFitter.h:48
double eval(double x) const
Evaluate the current density Gaussian model at the specified point.
GaussFitResult(double a, double x, double s)
Definition: GaussFitter.h:44
double sigma
parameter sigma of Gaussian distribution (width)
Definition: GaussFitter.h:54
GaussFitResult()
Definition: GaussFitter.h:42
double x0
parameter x0 of Gaussian distribution (center position)
Definition: GaussFitter.h:51