Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

HistogramDistribution.h

Go to the documentation of this file.
00001 // -*- C++ -*- 00002 00003 // HistogramDistribution.h 00004 // 00005 // Copyright (C) 2002 Yoshua Bengio, Pascal Vincent, Xavier Saint-Mleux 00006 // 00007 // Redistribution and use in source and binary forms, with or without 00008 // modification, are permitted provided that the following conditions are met: 00009 // 00010 // 1. Redistributions of source code must retain the above copyright 00011 // notice, this list of conditions and the following disclaimer. 00012 // 00013 // 2. Redistributions in binary form must reproduce the above copyright 00014 // notice, this list of conditions and the following disclaimer in the 00015 // documentation and/or other materials provided with the distribution. 00016 // 00017 // 3. The name of the authors may not be used to endorse or promote 00018 // products derived from this software without specific prior written 00019 // permission. 00020 // 00021 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 00022 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00023 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00024 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00025 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00026 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00027 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00028 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00029 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 // 00032 // This file is part of the PLearn library. For more information on the PLearn 00033 // library, go to the PLearn Web site at www.plearn.org 00034 00035 /* ******************************************************* 00036 * $Id: HistogramDistribution.h,v 1.12 2004/07/21 16:30:55 chrish42 Exp $ 00037 ******************************************************* */ 00038 00040 #ifndef HistogramDistribution_INC 00041 #define HistogramDistribution_INC 00042 00043 #include "PDistribution.h" 00044 #include <plearn/math/Binner.h> 00045 #include <plearn/math/Smoother.h> 00046 00047 namespace PLearn { 00048 using namespace std; 00049 00050 class HistogramDistribution: public PDistribution 00051 { 00052 protected: 00053 // ********************* 00054 // * protected options * 00055 // ********************* 00056 00057 public: 00059 Vec bin_positions; 00060 00063 Vec bin_density; 00064 00066 Vec survival_values; 00067 00069 PP<Binner> binner; 00070 00072 PP<Smoother> smoother; 00073 00075 bool smooth_density_instead_of_survival_fn; 00076 00077 typedef PDistribution inherited; 00078 00079 // ************************ 00080 // * public build options * 00081 // ************************ 00082 00083 // ### declare public option fields (such as build options) here 00084 // ... 00085 00086 // **************** 00087 // * Constructors * 00088 // **************** 00089 00090 // Default constructor, make sure the implementation in the .cc 00091 // initializes all fields to reasonable default values. 00092 HistogramDistribution(); 00093 00096 HistogramDistribution(VMat data, PP<Binner> binner_= 0, PP<Smoother> smoother_= 0); 00097 00098 // ****************** 00099 // * Object methods * 00100 // ****************** 00101 00102 private: 00104 // (Please implement in .cc) 00105 void build_(); 00106 00107 protected: 00109 // (Please implement in .cc) 00110 static void declareOptions(OptionList& ol); 00111 00112 public: 00113 // simply calls inherited::build() then build_() 00114 virtual void build(); 00115 00117 virtual void makeDeepCopyFromShallowCopy(map<const void*, void*>& copies); 00118 00120 PLEARN_DECLARE_OBJECT(HistogramDistribution); 00121 00122 // ******************* 00123 // * Learner methods * 00124 // ******************* 00125 00127 virtual void train(); 00128 00130 virtual void computeOutput(const Vec& input, Vec& output); 00131 00132 // ************************ 00133 // * Distribution methods * 00134 // ************************ 00135 00137 virtual double log_density(const Vec& x) const; 00138 00141 virtual double density(const Vec& x) const; 00142 00144 virtual double survival_fn(const Vec& x) const; 00145 00147 virtual double cdf(const Vec& x) const; 00148 00150 virtual void expectation(Vec& mu) const; 00151 00153 virtual void variance(Mat& cov) const; 00154 00156 virtual double prob_in_range(const Vec& x0, const Vec& x1) const; 00157 00158 //protected: 00159 //the following methods are used internally by HistogramDistribution 00160 public: 00162 int find_bin(real x) const; 00163 00165 void calc_density_from_survival(); 00167 void calc_survival_from_density(); 00168 00169 00171 static void calc_density_from_survival(const Vec& survival, Vec& density_, const Vec& positions); 00173 static void calc_survival_from_density(const Vec& density_, Vec& survival, const Vec& positions); 00174 00175 00176 }; 00177 00178 // Declares a few other classes and functions related to this class 00179 DECLARE_OBJECT_PTR(HistogramDistribution); 00180 00181 } // end of namespace PLearn 00182 00183 #endif

Generated on Tue Aug 17 15:54:59 2004 for PLearn by doxygen 1.3.7