Changes in lemon/random.h [102:81563e019fa4:68:a315a588a20d] in lemon
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/random.h
r102 r68 576 576 } 577 577 578 /// \brief Seeding random sequence579 ///580 /// Seeding the random sequence. The current number type will be581 /// 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 sequence588 ///589 /// Seeding the random sequence. The given range should contain590 /// any number type and the numbers will be converted to the591 /// 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 598 578 /// \brief Returns a random real number from the range [0, 1) 599 579 /// … … 824 804 } 825 805 826 /// Poisson distribution827 828 /// This function generates a Poisson distribution random number with829 /// parameter \c lambda.830 ///831 /// The probability mass function of this distribusion is832 /// \f[ \frac{e^{-\lambda}\lambda^k}{k!} \f]833 /// \note The algorithm is taken from the book of Donald E. Knuth titled834 /// ''Seminumerical Algorithms'' (1969). Its running time is linear in the835 /// 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 849 806 ///@} 850 807
Note: See TracChangeset
for help on using the changeset viewer.