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

PDistribution.h

Go to the documentation of this file.
00001 // -*- C++ -*- 00002 00003 // PDistribution.h 00004 // 00005 // Copyright (C) 2003 Pascal Vincent 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: PDistribution.h,v 1.17 2004/07/21 20:24:07 tihocan Exp $ 00037 ******************************************************* */ 00038 00040 #ifndef PDistribution_INC 00041 #define PDistribution_INC 00042 00043 #include <plearn_learners/generic/PLearner.h> 00044 00045 namespace PLearn { 00046 using namespace std; 00047 00048 class PDistribution: public PLearner 00049 { 00050 00051 private: 00052 00053 typedef PLearner inherited; 00054 00056 mutable Vec store_expect, store_result; 00057 mutable Mat store_cov; 00058 00059 protected: 00060 00061 // ********************* 00062 // * protected options * 00063 // ********************* 00064 00065 TVec<int> cond_sort; 00066 int n_input; 00067 int n_margin; 00068 int n_target; 00069 00070 // Fields below are not options. 00071 00075 bool already_sorted; 00076 00081 TVec<int> cond_swap; 00082 00084 real delta_curve; 00085 00089 bool full_joint_distribution; 00090 00091 mutable Vec input_part; 00092 mutable Vec target_part; 00093 00096 mutable bool need_set_input; 00097 00098 public: 00099 00100 // ************************ 00101 // * public build options * 00102 // ************************ 00103 00104 TVec<int> conditional_flags; 00105 real lower_bound, upper_bound; 00106 int n_curve_points; 00107 string outputs_def; 00108 Vec provide_input; 00109 00110 // **************** 00111 // * Constructors * 00112 // **************** 00113 00115 PDistribution(); 00116 00117 // ******************** 00118 // * PLearner methods * 00119 // ******************** 00120 00121 private: 00122 00124 void build_(); 00125 00126 protected: 00127 00129 static void declareOptions(OptionList& ol); 00130 00131 public: 00132 00133 // ************************ 00134 // **** Object methods **** 00135 // ************************ 00136 00138 virtual void build(); 00139 00141 virtual void makeDeepCopyFromShallowCopy(map<const void*, void*>& copies); 00142 00143 // Declares other standard object methods 00144 PLEARN_DECLARE_OBJECT(PDistribution); 00145 00146 // ************************** 00147 // **** PLearner methods **** 00148 // ************************** 00149 00151 virtual int outputsize() const; 00152 00155 virtual void forget(); 00156 00159 virtual void train(); 00160 00162 virtual void computeOutput(const Vec& input, Vec& output) const; 00163 00166 virtual void computeCostsFromOutputs(const Vec& input, const Vec& output, 00167 const Vec& target, Vec& costs) const; 00168 00169 // ******************************* 00170 // **** PDistribution methods **** 00171 // ******************************* 00172 00173 private: 00174 00180 void setConditionalFlagsWithoutUpdate(TVec<int>& flags); 00181 00182 protected: 00183 00188 bool ensureFullJointDistribution(TVec<int>& old_flags); 00189 00193 void finishConditionalBuild(); 00194 00196 void resizeParts(); 00197 00202 void sortFromFlags(Vec& v); 00203 void sortFromFlags(Mat& m, bool sort_columns = true, bool sort_rows = false); 00204 00210 bool splitCond(const Vec& input) const; 00211 00215 virtual void updateFromConditionalSorting(); 00216 00217 public: 00218 00220 void setConditionalFlags(TVec<int>& flags); 00221 00225 virtual void setInput(const Vec& input) const; 00226 00229 virtual void setTrainingSet(VMat training_set, bool call_forget=true); 00230 00232 virtual TVec<string> getTestCostNames() const; 00233 00235 virtual TVec<string> getTrainCostNames() const; 00236 00238 virtual real log_density(const Vec& y) const; 00239 00242 virtual real density(const Vec& y) const; 00243 00245 virtual real survival_fn(const Vec& y) const; 00246 00248 virtual real cdf(const Vec& y) const; 00249 00251 virtual void expectation(Vec& mu) const; 00252 00254 virtual void variance(Mat& cov) const; 00255 00257 virtual void resetGenerator(long g_seed) const; 00258 00260 virtual void generate(Vec& y) const; 00261 00264 void generateN(const Mat& Y) const; 00265 00266 }; 00267 00268 // Declares a few other classes and functions related to this class 00269 DECLARE_OBJECT_PTR(PDistribution); 00270 00271 } // end of namespace PLearn 00272 00273 #endif

Generated on Tue Aug 17 16:01:12 2004 for PLearn by doxygen 1.3.7