00001 00002 00003 // -*- C++ -*- 00004 00005 // ConditionalCDFSmoother.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: ConditionalCDFSmoother.h,v 1.6 2004/07/21 16:30:53 chrish42 Exp $ 00041 ******************************************************* */ 00042 00044 #ifndef ConditionalCDFSmoother_INC 00045 #define ConditionalCDFSmoother_INC 00046 00047 #include <plearn_learners/distributions/HistogramDistribution.h> 00048 #include "Smoother.h" 00049 00050 namespace PLearn { 00051 using namespace std; 00052 00053 class ConditionalCDFSmoother: public Smoother 00054 { 00055 protected: 00056 // ********************* 00057 // * protected options * 00058 // ********************* 00059 00060 // ### declare protected option fields (such as learnt parameters) here 00061 // ... 00062 00063 public: 00064 00065 typedef Smoother inherited; 00066 00067 // ************************ 00068 // * public build options * 00069 // ************************ 00070 00071 PP<HistogramDistribution> prior_cdf; 00072 00073 // **************** 00074 // * Constructors * 00075 // **************** 00076 00077 // Default constructor, make sure the implementation in the .cc 00078 // initializes all fields to reasonable default values. 00079 ConditionalCDFSmoother(); 00080 ConditionalCDFSmoother(PP<HistogramDistribution>& prior_cdf_); 00081 00082 // ****************** 00083 // * Object methods * 00084 // ****************** 00085 00086 private: 00088 // (Please implement in .cc) 00089 void build_(); 00090 00091 protected: 00093 // (Please implement in .cc) 00094 static void declareOptions(OptionList& ol); 00095 00096 public: 00097 // simply calls inherited::build() then build_() 00098 virtual void build(); 00099 00101 virtual void makeDeepCopyFromShallowCopy(map<const void*, void*>& copies); 00102 00104 PLEARN_DECLARE_OBJECT(ConditionalCDFSmoother); 00105 00106 00107 /**** 00108 * ConditionalCDFSmoother methods 00109 */ 00110 00111 public: 00112 // The source function is either f(i) = source_function[i] as a function of i 00113 // or if bin_positions is provided (non-zero length), 00114 // f(x) = source_function[i] 00115 // where i is s.t. bin_positions[i]>x>=bin_positions[i+1] 00116 // the optional bin_positions vector has length 0, or 1 more than source_function. 00117 // By default (if not provided) the dest_bin_positions are assumed the same as the source bin_positions. 00118 // Returns integral(smoothed_function). 00119 virtual real smooth(const Vec& source_function, Vec& smoothed_function, 00120 Vec bin_positions = Vec(), Vec dest_bin_positions = Vec()) const; 00121 00122 // real smooth(const HistogramCDF& source_cdf, HistogramCDF& dest_cdf); 00123 00124 }; 00125 00126 // Declares a few other classes and functions related to this class 00127 DECLARE_OBJECT_PTR(ConditionalCDFSmoother); 00128 00129 } // end of namespace PLearn 00130 00131 #endif