Changeset 3465
- Timestamp:
- Feb 10, 2016, 1:29:59 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/rnd.cc
r3446 r3465 7 7 Copyright (C) 2006 Jari Häkkinen 8 8 Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson 9 Copyright (C) 2012, 2015 Peter Johansson9 Copyright (C) 2012, 2015, 2016 Peter Johansson 10 10 11 11 This file is part of the yat library, http://dev.thep.lu.se/yat … … 66 66 geo(); 67 67 geo(0.1); 68 HyperGeometric hg; 69 hg(10, 100, 4); 70 HyperGeometric hg2(10, 100, 4); 71 hg2(); 72 hg2(11, 100, 4); 68 73 69 74 return suite.return_value(); -
trunk/yat/random/random.cc
r3446 r3465 3 3 /* 4 4 Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson 5 Copyright (C) 2009, 2011, 2012, 2013, 2015 Peter Johansson5 Copyright (C) 2009, 2011, 2012, 2013, 2015, 2016 Peter Johansson 6 6 7 7 This file is part of the yat library, http://dev.thep.lu.se/yat … … 325 325 326 326 327 HyperGeometric::HyperGeometric(void) 328 {} 329 330 331 HyperGeometric::HyperGeometric(unsigned int n1, unsigned int n2, 332 unsigned int t) 333 : n1_(n1), n2_(n2), t_(t) 334 {} 335 336 337 unsigned long int HyperGeometric::operator()(void) const 338 { 339 return (*this)(n1_, n2_, t_); 340 } 341 342 343 unsigned long int HyperGeometric::operator()(unsigned int n1, 344 unsigned int n2, 345 unsigned int t) const 346 { 347 return gsl_ran_hypergeometric(rng_->rng(), n1, n2, t); 348 } 349 350 327 351 Poisson::Poisson(const double m) 328 352 : m_(m) -
trunk/yat/random/random.h
r3446 r3465 6 6 /* 7 7 Copyright (C) 2005, 2006, 2007, 2008 Jari Häkkinen, Peter Johansson 8 Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Peter Johansson8 Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Peter Johansson 9 9 10 10 This file is part of the yat library, http://dev.thep.lu.se/yat … … 314 314 \since New in yat 0.10 315 315 */ 316 class Binomial : Discrete316 class Binomial : public Discrete 317 317 { 318 318 public: … … 483 483 484 484 /** 485 If we have \a n1 samples of type 1 and \a n2 samples of type 2 486 and draw \a t samples with replacement, number of drawn samples 487 of type 1 will follow the hyper geometric distribution. 488 489 \since New in yat 0.14 490 */ 491 class HyperGeometric : public Discrete 492 { 493 public: 494 /** 495 \brief Defaul constructor 496 */ 497 HyperGeometric(void); 498 499 /** 500 \brief Constructor 501 \param n1 number of samples of type 1 502 \param n2 number of samples of type 2 503 \param t number of samples to draw 504 */ 505 HyperGeometric(unsigned int n1, unsigned int n2, unsigned int t); 506 507 /** 508 \return random number from hypergeometric distribution using 509 parameters set in constructor. 510 */ 511 unsigned long int operator()(void) const; 512 513 /** 514 \return random number from hypergeometric distribution using 515 parameters passed. 516 */ 517 unsigned long int operator()(unsigned int n1, unsigned int n2, 518 unsigned int t) const; 519 private: 520 unsigned int n1_; 521 unsigned int n2_; 522 unsigned int t_; 523 }; 524 525 /** 485 526 @brief Poisson Distribution 486 527
Note: See TracChangeset
for help on using the changeset viewer.