IMP logo
IMP Reference Guide  2.10.0
The Integrative Modeling Platform
spb/Gaussian.h
Go to the documentation of this file.
1 /**
2  * \file IMP/spb/Gaussian.h \brief Gaussian function.
3  *
4  * Copyright 2007-2018 IMP Inventors. All rights reserved.
5  */
6 
7 #ifndef IMPSPB_GAUSSIAN_H
8 #define IMPSPB_GAUSSIAN_H
9 
10 #include <IMP/UnaryFunction.h>
11 #include <IMP/utility.h>
12 #include "spb_config.h"
13 
14 IMPSPB_BEGIN_NAMESPACE
15 
16 //! %Gaussian function (symmetric about the mean)
17 /**
18  Senes at al., JMB 366, 436 (2007)
19  */
20 class Gaussian : public UnaryFunction {
21  public:
22  /** Create with the given mean and the spring constant k */
23  Gaussian(Float Emin, Float Zmin, Float sigma)
24  : Emin_(Emin), Zmin_(Zmin), sigma_(sigma){};
25 
26  /*IMP_UNARY_FUNCTION_INLINE(Gaussian,
27  Emin_ * exp( - (feature - Zmin_) * (feature - Zmin_)
28  / sigma_ / sigma_ / 2.0 ),
29  - Emin_ * exp( - (feature - Zmin_)*(feature - Zmin_)
30  / sigma_ / sigma_ / 2.0 ) * (feature - Zmin_)
31  / sigma_ / sigma_,
32  "Gaussian: " << Emin_ << " and " << Zmin_
33  << " and " << sigma_ << std::endl);
34  */
35 
36  virtual DerivativePair evaluate_with_derivative(double feature) const
37  IMP_OVERRIDE {
38  return DerivativePair(evaluate(feature),
39  -Emin_ * exp(-(feature - Zmin_) * (feature - Zmin_) /
40  sigma_ / sigma_ / 2.0) *
41  (feature - Zmin_) / sigma_ / sigma_);
42  }
43 
44  virtual double evaluate(double feature) const IMP_OVERRIDE {
45  return Emin_ *
46  exp(-(feature - Zmin_) * (feature - Zmin_) / sigma_ / sigma_ / 2.0);
47  }
48 
50 
51  private:
52  Float Emin_;
53  Float Zmin_;
54  Float sigma_;
55 };
56 
57 IMPSPB_END_NAMESPACE
58 
59 #endif /* IMPSPB_GAUSSIAN_H */
Gaussian(Float Emin, Float Zmin, Float sigma)
Definition: spb/Gaussian.h:23
virtual double evaluate(double feature) const
Calculate score with respect to the given feature.
Definition: spb/Gaussian.h:44
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
virtual DerivativePair evaluate_with_derivative(double feature) const
Calculate score and derivative with respect to the given feature.
Definition: spb/Gaussian.h:36
Single variable function.
Gaussian function (symmetric about the mean)
Definition: spb/Gaussian.h:20
For backwards compatibility.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: types.h:23
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
Abstract single variable functor class for score functions.
Definition: UnaryFunction.h:25
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.