PLearn 0.1
|
00001 00002 00003 // -*- C++ -*- 00004 00005 // Distribution.h 00006 // 00007 // Copyright (C) *YEAR* *AUTHOR(S)* 00008 // ... 00009 // Copyright (C) *YEAR* *AUTHOR(S)* 00010 // 00011 // Redistribution and use in source and binary forms, with or without 00012 // modification, are permitted provided that the following conditions are met: 00013 // 00014 // 1. Redistributions of source code must retain the above copyright 00015 // notice, this list of conditions and the following disclaimer. 00016 // 00017 // 2. Redistributions in binary form must reproduce the above copyright 00018 // notice, this list of conditions and the following disclaimer in the 00019 // documentation and/or other materials provided with the distribution. 00020 // 00021 // 3. The name of the authors may not be used to endorse or promote 00022 // products derived from this software without specific prior written 00023 // permission. 00024 // 00025 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 00026 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00027 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 00028 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00029 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 00030 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00031 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00032 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00033 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00034 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00035 // 00036 // This file is part of the PLearn library. For more information on the PLearn 00037 // library, go to the PLearn Web site at www.plearn.org 00038 00039 /* ******************************************************* 00040 * $Id: Distribution.h 9418 2008-09-02 15:33:46Z nouiz $ 00041 ******************************************************* */ 00042 00044 #ifndef Distribution_INC 00045 #define Distribution_INC 00046 00047 #include <plearn_learners/generic/Learner.h> 00048 00049 namespace PLearn { 00050 using namespace std; 00051 00052 #ifdef __INTEL_COMPILER 00053 #pragma warning(disable:654) // Get rid of compiler warning. 00054 #endif 00055 00056 class Distribution: public Learner 00057 { 00058 protected: 00059 // ********************* 00060 // * protected options * 00061 // ********************* 00062 00063 // ### declare protected option fields (such as learnt parameters) here 00064 // ... 00065 00066 public: 00067 00068 typedef Learner inherited; 00069 00070 // ************************ 00071 // * public build options * 00072 // ************************ 00073 00076 string use_returns_what; 00077 00078 // **************** 00079 // * Constructors * 00080 // **************** 00081 00082 // Default constructor, make sure the implementation in the .cc 00083 // initializes all fields to reasonable default values. 00084 Distribution(); 00085 00086 00087 // ****************** 00088 // * Object methods * 00089 // ****************** 00090 00091 private: 00093 // (Please implement in .cc) 00094 void build_(); 00095 00096 protected: 00098 // (Please implement in .cc) 00099 static void declareOptions(OptionList& ol); 00100 00101 public: 00102 // simply calls inherited::build() then build_() 00103 virtual void build(); 00104 00106 virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies); 00107 00109 PLEARN_DECLARE_OBJECT(Distribution); 00110 00111 // ******************* 00112 // * Learner methods * 00113 // ******************* 00114 00116 virtual void train(VMat training_set); 00117 00119 virtual void use(const Vec& input, Vec& output); 00120 00121 00123 virtual double log_density(const Vec& x) const; 00124 00127 virtual double density(const Vec& x) const; 00128 00130 virtual double survival_fn(const Vec& x) const; 00131 00133 virtual double cdf(const Vec& x) const; 00134 00136 virtual Vec expectation() const; 00137 00139 virtual Mat variance() const; 00140 00142 virtual void generate(Vec& x) const; 00143 00144 }; 00145 00146 // Declares a few other classes and functions related to this class 00147 DECLARE_OBJECT_PTR(Distribution); 00148 00149 } // end of namespace PLearn 00150 00151 #ifdef __INTEL_COMPILER 00152 #pragma warning(default:654) 00153 #endif 00154 00155 #endif 00156 00157 00158 /* 00159 Local Variables: 00160 mode:c++ 00161 c-basic-offset:4 00162 c-file-style:"stroustrup" 00163 c-file-offsets:((innamespace . 0)(inline-open . 0)) 00164 indent-tabs-mode:nil 00165 fill-column:79 00166 End: 00167 */ 00168 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :