IMP  2.1.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-2013 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 {
34  public:
35  FNormal(double FA, double JA, double FM, double sigma):
36  base::Object("FNormal %1%"),
37  FA_(FA),
38  JA_(JA),
39  FM_(FM),
40  sigma_(sigma) {}
41 
42  /* energy (score) functions, aka -log(p) */
43  virtual double evaluate() const
44  {
45  return -log(JA_/sigma_) + 0.5*log(2*IMP::PI)
46  + 1/(2*square(sigma_))*square(FA_-FM_);
47  }
48 
49  //derivative of score wrt F(A)
50  virtual double evaluate_derivative_FA() const
51  { return (FA_-FM_)/square(sigma_); }
52 
53  virtual double evaluate_derivative_JA() const
54  { return -1/JA_; }
55 
56  //derivative wrt F(M)
57  virtual double evaluate_derivative_FM() const
58  { return (FM_-FA_)/square(sigma_); }
59 
60  virtual double evaluate_derivative_sigma() const
61  { return 1/sigma_ - square(FA_-FM_)/pow(sigma_,3); }
62 
63  /* probability density function */
64  virtual double density() const
65  {
66  return JA_/(sqrt(2*IMP::PI)*sigma_)*
67  exp(-square(FA_-FM_)/(2*square(sigma_)));
68  }
69 
70  /* change of parameters */
71  void set_FA(double f) {
72  FA_=f;
73  }
74  void set_JA(double f) {
75  JA_=f;
76  }
77  void set_FM(double f) {
78  FM_=f;
79  }
80  void set_sigma(double f) {
81  sigma_=f;
82  }
83 
85  /*IMP_OBJECT_INLINE(FNormal, out << "FNormal: " << FA_ << ", " << JA_
86  << ", " << FM_ << ", " << sigma_ <<std::endl, {});*/
87 
88  private:
89  double FA_,JA_,FM_,sigma_;
90 };
91 
92 IMPISD_END_NAMESPACE
93 
94 #endif /* IMPISD_FNORMAL_H */
static const double PI
the constant pi
Import IMP/kernel/constants.h in the namespace.
Import IMP/kernel/macros.h in the namespace.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Storage of a model, its restraints, constraints and particles.
Common base class for heavy weight IMP objects.
FNormal.
Definition: FNormal.h:32