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

ConditionalDistribution.cc

Go to the documentation of this file.
00001 00002 00003 // -*- C++ -*- 00004 00005 // ConditionalDistribution.cc 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 #include "ConditionalDistribution.h" 00040 00041 namespace PLearn { 00042 using namespace std; 00043 00044 ConditionalDistribution::ConditionalDistribution() 00045 :inherited() 00046 { 00047 00048 } 00049 00050 00051 PLEARN_IMPLEMENT_OBJECT(ConditionalDistribution, "ONE LINE DESCR", 00052 "You must call setInput to set the condition before using the distribution"); 00053 00054 00055 void ConditionalDistribution::makeDeepCopyFromShallowCopy(map<const void*, void*>& copies) 00056 { 00057 inherited::makeDeepCopyFromShallowCopy(copies); 00058 } 00059 00060 00061 void ConditionalDistribution::setInput(const Vec& input) 00062 { PLERROR("setInput must be implemented for this ConditionalDistribution"); } 00063 00064 00065 void ConditionalDistribution::use(const Vec& input, Vec& output) 00066 { 00067 Vec x = input.subVec(0,input_part_size); 00068 Vec y = input.subVec(input_part_size,input.length()-input_part_size); 00069 setInput(x); 00070 if (use_returns_what=="l") 00071 output[0]=log_density(y); 00072 else if (use_returns_what=="d") 00073 output[0]=density(y); 00074 else if (use_returns_what=="c") 00075 output[0]=cdf(y); 00076 else if (use_returns_what=="s") 00077 output[0]=survival_fn(y); 00078 else if (use_returns_what=="e") 00079 output << expectation(); 00080 else if (use_returns_what=="v") 00081 output << variance().toVec(); 00082 } 00083 00084 } // end of namespace PLearn

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