COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/random.h

    r102 r68  
    576576    }
    577577
    578     /// \brief Seeding random sequence
    579     ///
    580     /// Seeding the random sequence. The current number type will be
    581     /// converted to the architecture word type.
    582     template <typename Number>
    583     void seed(Number seed) {
    584       _random_bits::Initializer<Number, Word>::init(core, seed);
    585     }
    586 
    587     /// \brief Seeding random sequence
    588     ///
    589     /// Seeding the random sequence. The given range should contain
    590     /// any number type and the numbers will be converted to the
    591     /// architecture word type.
    592     template <typename Iterator>
    593     void seed(Iterator begin, Iterator end) {
    594       typedef typename std::iterator_traits<Iterator>::value_type Number;
    595       _random_bits::Initializer<Number, Word>::init(core, begin, end);
    596     }
    597 
    598578    /// \brief Returns a random real number from the range [0, 1)
    599579    ///
     
    824804    } 
    825805     
    826     /// Poisson distribution
    827 
    828     /// This function generates a Poisson distribution random number with
    829     /// parameter \c lambda.
    830     ///
    831     /// The probability mass function of this distribusion is
    832     /// \f[ \frac{e^{-\lambda}\lambda^k}{k!} \f]
    833     /// \note The algorithm is taken from the book of Donald E. Knuth titled
    834     /// ''Seminumerical Algorithms'' (1969). Its running time is linear in the
    835     /// return value.
    836    
    837     int poisson(double lambda)
    838     {
    839       const double l = std::exp(-lambda);
    840       int k=0;
    841       double p = 1.0;
    842       do {
    843         k++;
    844         p*=real<double>();
    845       } while (p>=l);
    846       return k-1;
    847     } 
    848      
    849806    ///@}
    850807   
Note: See TracChangeset for help on using the changeset viewer.