Shark Machine Learning Library
  • About Shark
  • Sourceforge
    • Project Summary
    • Downloads
    • Subversion Repository
  • Getting Started
  • Tutorials
  • FAQ
  • Main Modules
    • ReClaM
    • EALib
    • MOO-EALib
    • Fuzzy
  • Tools
    • Mixture
    • Array
    • Rng
    • LinAlg
    • FileUtil
  • Main Page
  • Classes

Normal.h

Go to the documentation of this file.
00001 //===========================================================================
00041 //===========================================================================
00042 
00043 
00044 #ifndef __NORMAL_H
00045 #define __NORMAL_H
00046 
00047 #include <cmath>
00048 #include "Rng/RandomVar.h"
00049 
00050 
00051 //===========================================================================
00090 class Normal : public RandomVar< double >
00091 {
00092 public:
00093 
00097     Normal(double mean = 0, double variance = 1);
00098 
00099 
00104     Normal(double mean, double variance, RNG& r);
00105 
00106     //========================================================================
00131     void seed(long s)
00132     {
00133         RandomVar< double >::seed(s); iset = false;
00134     }
00135 
00136 
00137     //========================================================================
00154     double mean() const
00155     {
00156         return pMean;
00157     }
00158 
00159 
00160     //========================================================================
00184     double variance() const
00185     {
00186         return pStdDev * pStdDev;
00187     }
00188 
00189 
00190     //========================================================================
00208     void   mean(double newMean)
00209     {
00210         pMean = newMean;
00211     }
00212 
00213     //========================================================================
00236     void   variance(double newVar)
00237     {
00238         pStdDev = sqrt(newVar);
00239     }
00240 
00243     double operator()(double mean, double variance);
00244 
00248     double operator()();
00249 
00253     double p(const double&) const;
00254 
00255 protected:
00256 
00258     double pMean;
00259 
00261     double pStdDev;
00262 
00263 private:
00264 
00265     // If set to "true", the second normally distributed
00266     // random number, generated one step before, was
00267     // stored in "gset" and can be returned at once. Otherwise,
00268     // two new random numbers must be generated.
00269     bool   iset;
00270 
00271     // The second generated normally distributed random number
00272     // is stored here, when "iset" is set to "true".
00273     double gset;
00274 
00275 };
00276 
00277 #endif  /* !__NORMAL_H */
00278