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

ConditionalStatsCollector.h

Go to the documentation of this file.
00001 // -*- C++ -*- 00002 00003 // ConditionalStatsCollector.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: ConditionalStatsCollector.h,v 1.6 2004/07/21 16:30:53 chrish42 Exp $ 00037 ******************************************************* */ 00038 00039 // Authors: Pascal Vincent 00040 00044 #ifndef ConditionalStatsCollector_INC 00045 #define ConditionalStatsCollector_INC 00046 00047 #include <plearn/base/Object.h> 00048 #include "TMat.h" 00049 #include <plearn/base/RealMapping.h> 00050 00051 namespace PLearn { 00052 using namespace std; 00053 00054 class ConditionalStatsCollector: public Object 00055 { 00056 public: 00057 typedef Object inherited; 00058 00059 protected: 00060 // ********************* 00061 // * protected options * 00062 // ********************* 00063 00064 // ### declare protected option fields (such as learnt parameters) here 00065 // ... 00066 00067 public: 00068 00069 // ************************ 00070 // * options * 00071 // ************************ 00072 00074 int condvar; 00075 00077 TVec<RealMapping> ranges; 00078 00083 TVec< TMat<double> > counts; 00084 00087 TVec< TMat<double> > sums; 00088 00091 TVec< TMat<double> > sums_condvar; 00092 00095 TVec< TMat<double> > sumsquares; 00096 00099 TVec< TMat<double> > sumsquares_condvar; 00100 00103 TVec< TMat<double> > minima; 00104 00107 TVec< TMat<double> > minima_condvar; 00108 00111 TVec< TMat<double> > maxima; 00112 00115 TVec< TMat<double> > maxima_condvar; 00116 00117 // **************** 00118 // * Methods 00119 // **************** 00120 00121 public: 00122 00123 // Default constructor, make sure the implementation in the .cc 00124 // initializes all fields to reasonable default values. 00125 ConditionalStatsCollector(); 00126 00128 void setBinMappingsAndCondvar(const TVec<RealMapping>& the_ranges, int the_condvar); 00129 00131 void forget(); 00132 00134 void update(const Vec& v, real weight = 1.0); 00135 00136 protected: 00140 int findrange(int varindex, real val) const; 00141 00142 // ****************** 00143 // * Object methods * 00144 // ****************** 00145 00146 private: 00148 // (PLEASE IMPLEMENT IN .cc) 00149 void build_(); 00150 00151 protected: 00153 // (PLEASE IMPLEMENT IN .cc) 00154 static void declareOptions(OptionList& ol); 00155 00156 public: 00157 // Declares other standard object methods 00158 // If your class is not instantiatable (it has pure virtual methods) 00159 // you should replace this by PLEARN_DECLARE_ABSTRACT_OBJECT_METHODS 00160 PLEARN_DECLARE_OBJECT(ConditionalStatsCollector); 00161 00162 // simply calls inherited::build() then build_() 00163 virtual void build(); 00164 00166 // (PLEASE IMPLEMENT IN .cc) 00167 virtual void makeDeepCopyFromShallowCopy(map<const void*, void*>& copies); 00168 00169 }; 00170 00171 // Declares a few other classes and functions related to this class 00172 DECLARE_OBJECT_PTR(ConditionalStatsCollector); 00173 00174 } // end of namespace PLearn 00175 00176 #endif

Generated on Tue Aug 17 15:50:22 2004 for PLearn by doxygen 1.3.7