latest version v1.9 - last update 10 Apr 2010 |
00001 /* 00002 * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 00003 * Lehrstuhl fuer Technische Informatik, RWTH-Aachen, Germany 00004 * 00005 * This file is part of the LTI-Computer Vision Library (LTI-Lib) 00006 * 00007 * The LTI-Lib is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License (LGPL) 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * The LTI-Lib is distributed in the hope that it will be 00013 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00014 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with the LTI-Lib; see the file LICENSE. If 00019 * not, write to the Free Software Foundation, Inc., 59 Temple Place - 00020 * Suite 330, Boston, MA 02111-1307, USA. 00021 */ 00022 00023 00024 /*---------------------------------------------------------------- 00025 * project ....: LTI Digital Image/Signal Processing Library 00026 * file .......: ltiPoissonDist.h 00027 * authors ....: Thomas Rusert 00028 * organization: LTI, RWTH Aachen 00029 * creation ...: 21.04.99 00030 * revisions ..: $Id: ltiPoissonDist.h,v 1.5 2006/02/08 12:39:17 ltilib Exp $ 00031 */ 00032 00033 #ifndef _LTI_POISSONDIST_H_ 00034 #define _LTI_POISSONDIST_H_ 00035 00036 #include "ltiContinuousRandDist.h" 00037 00038 namespace lti { 00039 /** 00040 * Poisson distributed random number class. 00041 */ 00042 class poissonDistribution : public continuousRandomDistribution { 00043 public: 00044 /** 00045 * parameters class for the poisson distribution 00046 */ 00047 class parameters : public continuousRandomDistribution::parameters { 00048 public: 00049 /** 00050 * default constructor 00051 */ 00052 parameters() : mu(1) {}; 00053 00054 /** 00055 * copy constructor 00056 */ 00057 parameters(const parameters& other) 00058 : continuousRandomDistribution::parameters() {copy(other);}; 00059 00060 /** 00061 * destructor 00062 */ 00063 ~parameters() {}; 00064 00065 /** 00066 * mean 00067 */ 00068 double mu; 00069 00070 /** 00071 * copy data of "other" parameters 00072 */ 00073 parameters& copy(const parameters& other) { 00074 00075 #ifndef _LTI_MSC_6 00076 // MS Visual C++ 6 is not able to compile this... 00077 continuousRandomDistribution::parameters::copy(other); 00078 #else 00079 // ...so we have to use this workaround. 00080 // Conditional on that, copy may not be virtual. 00081 continuousRandomDistribution::parameters& 00082 (continuousRandomDistribution::parameters::* p_copy) 00083 (const continuousRandomDistribution::parameters&) = 00084 continuousRandomDistribution::parameters::copy; 00085 (this->*p_copy)(other); 00086 #endif 00087 00088 mu = other.mu; 00089 00090 return (*this); 00091 } 00092 00093 /** 00094 * returns a pointer to a clone of the parameters. 00095 */ 00096 virtual functor::parameters* clone() const { 00097 return (new parameters(*this)); 00098 }; 00099 00100 /** 00101 * returns the name of this type 00102 */ 00103 virtual const char* getTypeName() const { 00104 return "poissonDistribution::parameters"; 00105 }; 00106 }; 00107 00108 /** 00109 * default constructor. 00110 */ 00111 poissonDistribution() : continuousRandomDistribution() {}; 00112 00113 /** 00114 * constructor, sets mean. 00115 */ 00116 poissonDistribution(const double mean); 00117 00118 /** 00119 * constructor, sets the parameters. 00120 */ 00121 poissonDistribution(const parameters& theParams); 00122 00123 /** 00124 * destructor 00125 */ 00126 virtual ~poissonDistribution() {}; 00127 00128 /** 00129 * returns the current parameters. 00130 */ 00131 const parameters& getParameters() const; 00132 00133 /** 00134 * returns as a floating-point number an integer value that is a 00135 * random deviate drawn from a Poisson distribution of the given mean. 00136 */ 00137 virtual double draw() const; 00138 00139 /** 00140 * copy data of "other" functor. 00141 */ 00142 poissonDistribution& copy(const poissonDistribution& other); 00143 00144 /** 00145 * returns a pointer to a clone of the functor. 00146 */ 00147 virtual functor* clone() const { 00148 return (new poissonDistribution(*this)); 00149 }; 00150 00151 /** 00152 * returns the name of this type 00153 */ 00154 virtual const char* getTypeName() const { 00155 return "poissonDistribution"; 00156 }; 00157 00158 protected: 00159 mutable double sq, alxm, g, oldm; 00160 }; 00161 } 00162 00163 #endif