Ignore:
Timestamp:
Aug 5, 2005, 1:55:16 PM (16 years ago)
Author:
Peter
Message:

added docs for random

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/random/Random.h

    r366 r367  
    4141  ///
    4242  /// @brief continuous random distributions.
    43   /// Base for continuous random distributions.
     43  ///
     44  /// Abstract base class for continuous random distributions.
    4445  ///
    4546  class RandomContinuous
     
    5253    inline RandomContinuous(void) { rng_=RNG::instance(89); }
    5354
     55    ///
     56    /// @return A random number
     57    ///
    5458    virtual double operator()(void) const = 0;
    5559
     
    6266  /// @brief Uniform distribution
    6367  ///
    64   /// Class for generating a random number from a flat distribution
     68  /// Class for generating a random number from a uniform distribution
    6569  /// between zero and unity.
    6670  ///
    67   /// Distribution function \f$ f(x) = 1 \f$ for \f$ 0 \le x < 1 \f$
    68   /// Expectation value: 0.5
     71  /// Distribution function \f$ f(x) = 1 \f$ for \f$ 0 \le x < 1 \f$ \n
     72  /// Expectation value: 0.5 \n
    6973  /// Variance: \f$ \frac{1}{12} \f$
    7074  ///
     
    7882
    7983  ///
    80   /// Class to generate Gaussian random numbers.
     84  /// @brief Gaussian distribution
     85  ///
     86  /// Class for generating a random number from a Gaussian
     87  /// distribution between zero and unity. Utilizes the Box-Muller
     88  /// algorithm, which needs two calls to random generator.
     89  ///
     90  /// Distribution function \f$ f(x) =
     91  /// \frac{1}{\sqrt{2\pi\sigma^2}}\exp(-\frac{(x-\mu)^2}{2\sigma^2})
     92  /// \f$ \n
     93  /// Expectation value: \f$ \mu \f$ \n
     94  /// Variance: \f$ \sigma^2 \f$
    8195  ///
    8296  class RandomGaussian : public RandomContinuous
    8397  {
    8498  public:
     99    ///
     100    /// @brief Constructor
     101    /// @param s is the standard deviation \f$ \sigma \f$ of distribution
     102    /// m is the expectation value \f$ \mu \f$ of the distribution
     103    ///
    85104    inline RandomGaussian(const double s=1, const double m=0)
    86105      : m_(m), s_(s) {}
    87106
     107    ///
     108    /// @return A random Gaussian number
     109    ///
    88110    inline double operator()(void) const
    89111    { return gsl_ran_gaussian(rng_->rng(), s_)+m_; }
    90112
     113    ///
     114    /// @return A random Gaussian number with standard deviation \a s
     115    /// and expectation value 0.
     116    /// @note this operator ignores parameters given in Constructor
     117    ///
    91118    inline double operator()(const double s) const
    92119    { return gsl_ran_gaussian(rng_->rng(), s); }
    93120
     121    ///
     122    /// @return A random Gaussian number with standard deviation \a s
     123    /// and expectation value \a m.
     124    /// @note this operator ignores parameters given in Constructor
     125    ///
    94126    inline double operator()(const double s, const double m) const
    95127    { return gsl_ran_gaussian(rng_->rng(), s)+m; }
     
    101133
    102134  ///
    103   /// @brief exponential
     135  /// @brief Exponential distribution
     136  ///
     137  /// Class for generating a random number from a Exponential
     138  /// distribution.
     139  ///
     140  /// Distribution function \f$ f(x) = \frac{1}{m}\exp(-x/a) \f$ for
     141  /// \f$ x \f$ \n
     142  /// Expectation value: \f$ m \f$ \n
     143  /// Variance: \f$ m^2 \f$
    104144  ///
    105145  class RandomExponential : public RandomContinuous
     
    107147  public:
    108148    ///
    109     /// Constructor
     149    /// @brief Constructor
     150    /// @param m is the expectation value of the distribution.
    110151    ///
    111152    inline RandomExponential(const double m=1)
     
    113154
    114155    ///
    115     ///
     156    /// @return A random number from exponential distribution
    116157    ///
    117158    inline double operator()(void) const
     
    119160
    120161    ///
    121     ///
    122     ///
     162    /// @return A random number from exponential distribution, with
     163    /// expectation value \a m
     164    /// @note this operator ignores parameters given in Constructor
     165    ///
    123166    inline double operator()(const double m) const
    124167    { return gsl_ran_exponential(rng_->rng(), m); }
     
    131174  ///
    132175  /// @brief discrete random distributions.
    133   /// Base for discrete random distributions.
     176  ///
     177  /// Abstract Base Class for discrete random distributions. Given K
     178  /// discrete events with different probabilities \f$ P[k] \f$,
     179  /// produce a random value k consistent with its probability.
    134180  ///
    135181  class RandomDiscrete
     
    137183  public:
    138184    ///
    139     /// Constructor
     185    /// @brief Constructor
    140186    ///
    141187    inline RandomDiscrete(void) { rng_=RNG::instance(89); }
    142188
    143189    ///
    144     /// Common interface for all Discrete Random Classes
     190    /// @return A random number.
    145191    ///
    146192    virtual long operator()(void) const = 0;
     
    150196  };
    151197
     198  ///
     199  /// @brief Discrete uniform distribution
     200  ///
     201  /// Discrete uniform distribution also known as the "equally likely
     202  /// outcomes" distribution. Each outcome, in this case an integer
     203  /// from \f$ [a,b) \f$, have equal probability to occur.
     204  ///
     205  /// Distribution function \f$ p(k) = \frac{1}{b-a} \f$ for \f$ a \le
     206  /// k < b \f$ \n
     207  /// Expectation value: \f$ \frac{a+b}{2} \f$ \n
     208  /// Variance: \f$ \frac{1}{3}((b-a)^2-1) \f$
     209  ///
    152210
    153211  class RandomDiscreteUniform : public RandomDiscrete
     
    155213  public:
    156214    ///
    157     /// Constructor.
     215    /// @brief Constructor.
     216    ///
     217    /// @param \a range is number of different integers that can be
     218    /// generated \f$ (b-a+1) \f$ \a min is the minimal integer that
     219    /// can be generated \f$ (a) \f$
    158220    ///
    159221    inline RandomDiscreteUniform(const u_long range, const long min=0)
     
    174236    ///
    175237    /// @return A random number between \a min and \a range - \a min
     238    /// @note this operator ignores parameters given in Constructor
    176239    ///
    177240    inline long operator()(const u_long range, const long min) const
     
    186249
    187250  ///
    188   /// @brief Poisson
    189   ///
    190   class RandomPoisson : public RandomContinuous
    191   {
    192   public:
    193     ///
    194     /// Constructor
    195     ///
     251  /// @brief Poisson Distribution
     252  ///
     253  /// Having a Poisson process (no memory), number of occurences
     254  /// within a given time window is Poisson distributed. This
     255  /// distribution is the limit of a Binomial distribution when number
     256  /// of attempts is large, and the probability for one attempt to be
     257  /// succesful is small (in such a way that the expected number of
     258  /// succesful attempts is \f$ m \f$.
     259  ///
     260  /// Probability function \f$ p(k) = e^{-m}\frac{m^k}{k!} \f$ for \f$ 0 \le
     261  /// k  \f$ \n
     262  /// Expectation value: \f$ m \f$ \n
     263  /// Variance: \f$ m \f$
     264  ///
     265  class RandomPoisson : public RandomDiscrete
     266  {
     267  public:
     268    ///
     269    /// @brief Constructor
     270    ///
     271    /// @param m is expectation value
    196272    inline RandomPoisson(const double m=1)
    197273      : m_(m){}
    198274
    199275    ///
    200     ///
     276    /// @return a Poisson distributed number.
    201277    ///
    202278    inline double operator()(void) const
     
    204280
    205281    ///
    206     ///
    207     ///
     282    /// @return a Poisson distributed number with expectation value \a
     283    /// m
     284    /// @note this operator ignores parameters set in Constructor
    208285    inline double operator()(const double m) const
    209286    { return gsl_ran_poisson(rng_->rng(), m); }
Note: See TracChangeset for help on using the changeset viewer.