• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • Examples
  • File List
  • File Members

/home/hauberg/Dokumenter/Capture/humim-tracker-0.1/src/simulator.h

Go to the documentation of this file.
00001 // Copyright (C) 2011 Soren Hauberg
00002 //
00003 // This program is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU General Public License
00005 // as published by the Free Software Foundation; either version 3
00006 // of the License, or (at your option) any later version.
00007 //
00008 // This program is distributed in the hope that it will be useful, but
00009 // WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU General Public License
00014 // along with this program; if not, see <http://www.gnu.org/licenses/>.
00015  
00016 #ifndef SIMULATOR
00017 #define SIMULATOR
00018 
00019 #include <vector>
00020 
00024 template<typename T> class simulator
00025 {
00026 public:
00027   virtual T random () const = 0; // simulate
00028   virtual double pdf (const T) const = 0; // probability density
00029   virtual double cdf (const T) const = 0; // cumulative density
00030   virtual ~simulator ()
00031     {
00032     }
00033 };
00034 
00038 class uniform : public simulator<double>
00039 {
00040 public:
00041   double pdf (const double) const;
00042   double cdf (const double) const;
00043   double random () const;
00044 };
00045 
00049 class gaussian1D : public simulator<double>
00050 {
00051 public:
00052   gaussian1D (const double m = 0, const double s = 1);
00053   double pdf (const double) const;
00054   double random () const;
00055   double cdf (const double) const;
00056 
00057 private:
00058   const double mu;
00059   const double sigma;
00060 };
00061 
00065 class von_mises : public simulator<double>
00066 {
00067 public:
00068   von_mises (const double m = 0, const double k = 1);
00069   double pdf (const double) const;
00070   double random () const;
00071   double cdf (const double) const;
00072 
00073 private:
00074   const double mu;
00075   const double kappa;
00076   uniform uni;
00077 };
00078 
00082 class exponential : public simulator<double>
00083 {
00084 public:
00085   exponential (const double m = 1.0);
00086   double pdf (const double) const;
00087   double random () const;
00088   double cdf (const double) const;
00089 
00090 private:
00091   const double mu;
00092 };
00093 
00097 class chi_square : public simulator<double>
00098 {
00099 public:
00100   chi_square (const int n0 = 1);
00101   double cdf (const double) const;
00102   double pdf (const double) const;
00103   double random () const;
00104 
00105 private:
00106   const int n;
00107 };
00108 
00112 class rayleigh : public simulator<double>
00113 {
00114 public:
00115   rayleigh (const double);
00116   double pdf (const double) const;
00117   double cdf (const double) const;
00118   double random () const;
00119 
00120 private:
00121   const double mu;
00122 };
00123 
00127 class discrete : public simulator<int>
00128 {
00129 public:
00130   discrete (const std::vector<double> &p);
00131   double pdf (const int) const;
00132   double cdf (const int) const;
00133   int random () const;
00134 
00135 private:
00136   const std::vector<double> prob;
00137   std::vector<double> cum_sum;
00138   const int nb;
00139 };
00140 
00141 #endif

Generated on Thu Dec 1 2011 12:54:02 for HUMIM Tracker by  doxygen 1.7.1