IMP  2.3.1
The Integrative Modeling Platform
FNormal.h
Go to the documentation of this file.
1 /**
2  * \file IMP/isd/FNormal.h \brief Normal distribution of Function
3  *
4  * Copyright 2007-2014 IMP Inventors. All rights reserved.
5  */
6 
7 #ifndef IMPISD_FNORMAL_H
8 #define IMPISD_FNORMAL_H
9 
10 #include <IMP/isd/isd_config.h>
11 #include <IMP/macros.h>
12 #include <IMP/kernel/Model.h>
13 #include <IMP/constants.h>
14 #include <math.h>
15 
16 IMPISD_BEGIN_NAMESPACE
17 
18 //! FNormal
19 /** Probability density function and -log(p) of normal sampling from some
20  * function F. If A is drawn from the F-Normal distribution then F(A) is drawn
21  * from a normal distribution with mean M and standard deviation sigma.
22  * Arguments: F(A), J(A) the derivative of F w/r to A, F(M) and sigma. The
23  * distribution is normalized with respect to the variable A.
24  *
25  * Example: if F is the log function, the F-normal distribution is the
26  * lognormal distribution with mean M and standard deviation sigma.
27  *
28  * NOTE: for now, F must be monotonically increasing, so that JA > 0. The
29  * program will not check for that.
30  */
31 
32 class IMPISDEXPORT FNormal : public base::Object {
33  public:
34  FNormal(double FA, double JA, double FM, double sigma)
35  : base::Object("FNormal %1%"), FA_(FA), JA_(JA), FM_(FM), sigma_(sigma) {}
36 
37  /* energy (score) functions, aka -log(p) */
38  virtual double evaluate() const {
39  return -log(JA_ / sigma_) + 0.5 * log(2 * IMP::PI) +
40  1 / (2 * square(sigma_)) * square(FA_ - FM_);
41  }
42 
43  // derivative of score wrt F(A)
44  virtual double evaluate_derivative_FA() const {
45  return (FA_ - FM_) / square(sigma_);
46  }
47 
48  virtual double evaluate_derivative_JA() const { return -1 / JA_; }
49 
50  // derivative wrt F(M)
51  virtual double evaluate_derivative_FM() const {
52  return (FM_ - FA_) / square(sigma_);
53  }
54 
55  virtual double evaluate_derivative_sigma() const {
56  return 1 / sigma_ - square(FA_ - FM_) / pow(sigma_, 3);
57  }
58 
59  /* probability density function */
60  virtual double density() const {
61  return JA_ / (sqrt(2 * IMP::PI) * sigma_) *
62  exp(-square(FA_ - FM_) / (2 * square(sigma_)));
63  }
64 
65  /* change of parameters */
66  void set_FA(double f) { FA_ = f; }
67  void set_JA(double f) { JA_ = f; }
68  void set_FM(double f) { FM_ = f; }
69  void set_sigma(double f) { sigma_ = f; }
70 
72  /*IMP_OBJECT_INLINE(FNormal, out << "FNormal: " << FA_ << ", " << JA_
73  << ", " << FM_ << ", " << sigma_ <<std::endl, {});*/
74 
75  private:
76  double FA_, JA_, FM_, sigma_;
77 };
78 
79 IMPISD_END_NAMESPACE
80 
81 #endif /* IMPISD_FNORMAL_H */
Declare an efficient stl-compatible map.
static const double PI
the constant pi
Import IMP/kernel/constants.h in the namespace.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Import IMP/kernel/macros.h in the namespace.
Storage of a model, its restraints, constraints and particles.
Common base class for heavy weight IMP objects.
Definition: Object.h:106
FNormal.
Definition: FNormal.h:32