Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MixtureFunc.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file src/core/scoring/constraints/MixtureFunc.hh
11 /// @brief Definition for functions used in definition of constraints.
12 /// @author James Thompson
13 
14 #ifndef INCLUDED_core_scoring_constraints_MixtureFunc_hh
15 #define INCLUDED_core_scoring_constraints_MixtureFunc_hh
16 
18 #include <core/types.hh>
19 
20 // C++ Headers
21 
22 namespace core {
23 namespace scoring {
24 namespace constraints {
25 
26 /// @brief Derived class of class Func representing a Mixture of several distinct functions. The
27 /// function is of the form ln( g(r) / h(r) ), where g(r) is a mixture of a Gaussian and Exponential
28 /// distributions, and h(r) is a Gaussian distribution. See methods and implementation for more
29 /// information.
30 class MixtureFunc : public Func {
31 public:
32 
33  /*!
34  * Constructor for MixtureFunc. Arguments to the constructor are:
35  * - anchor: parameter representing the value at which this function is anchored, represents the
36  * mean of the Gaussian distribution and the highest point of the exponential distribution.
37  * - gaussian_param: parameter for Gaussian portion of g(r), representing the standard deviation
38  * of a Gaussian distribution around anchor.
39  * - exp_param: parameter for Exponential portion of g(r), representing the rate at which
40  * the exponential distribution drops off from anchor.
41  * - mixture_param: parameter describing the mixture of the Gaussian and Exponential functions
42  * that make up g(r).
43  * - bg_mean: parameter representing the mean of h(r).
44  * - bg_sd: parameter representing the standard deviation of h(r).
45  */
46 
48  Real const anchor,
49  Real const gaussian_param,
50  Real const exp_param,
51  Real const mixture_param,
52  Real const bg_mean,
53  Real const bg_sd
54  ) :
55  fmax_ ( 0.0 ), // this is always read, but not always initialized. Is this a good value?
56  anchor_ ( anchor ),
57  gaussian_param_( gaussian_param ),
58  exp_param_ ( exp_param ),
59  mixture_param_ ( mixture_param ),
60  bg_mean_ ( bg_mean ),
61  bg_sd_ ( bg_sd )
62  {
63  if ( anchor_ > 1e-10 )
65  }
66 
67  /// @brief returns a clone of this MixtureFunc
68  FuncOP clone() const { return new MixtureFunc( *this ); }
69 
70  /// @brief Returns the value of this MixtureFunc evaluated at distance x.
71  Real func( Real const x ) const;
72 
73  /// @brief Returns the value of the first derivative of this MixtureFunc at distance x.
74  Real dfunc( Real const x ) const;
75 
76  /// @brief show the definitio of this MixtureFunc to the specified output stream.
77  virtual void show_definition( std::ostream &out ) const;
78 
79  /// @brief Function that's used for debugging. Given x, this calculates
80  /// g(x), h(x), g'(x) and h'(x).
81  Real
83  Real const x,
84  Real & g,
85  Real & h,
86  Real & g_prime,
87  Real & h_prime
88  ) const;
89 
90  /// @brief Calculates the K-L divergence between the inferred and background distributions.
91  Real calc_kl_divergence() const;
92 
93  /// @brief Prints this MixtureFunc to the given ostream.
94  virtual void show( std::ostream& out ) const;
95 
96  /// @brief Calls show( out ) on this MixtureFunc.
97  friend std::ostream& operator<<( std::ostream& out, const MixtureFunc& f ) {
98  f.show( out );
99  return out;
100  } // operator<<
101 
102  /// @brief
103  /// The parameters are:
104  /*!
105  * Initializes this MixtureFunc from the given istream. An example
106  * of the type of string from which the istream should be constructed is:
107  * "MIXTUREFUNC 6.9734 3.598 0.222 0.872 19.396 7.643". The interpretation is to
108  * create initialize this MixtureFunc object with the following parameters:
109  * - anchor 6.9734
110  * - gaussian_param 3.598
111  * - exp_param 0.222
112  * - mixture_param 0.872
113  * - bg_mean 19.396
114  * - bg_sd 7.643
115  */
116  void read_data( std::istream& in );
117 
118  /// @brief Returns the value of this MixtureFunc evaluated at distance x.
119  Real func_( Real x ) const;
120 
121 
122 private:
123  void verify_parameters_();
124 
125  // Real distance_cutoff_;
134 };
135 
136 
137 
138 }
139 }
140 }
141 
142 #endif