Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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;
00028 virtual double pdf (const T) const = 0;
00029 virtual double cdf (const T) const = 0;
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