Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

distrib.h

00001 //==========================================================================
00002 // file distrib.h
00003 //
00004 // Random variate generation
00005 //
00006 // @author Werner Sandmann (ws), Kay Michael Masslow (kmm)
00007 //
00008 // @date 11/26/2002 "doxygenification" (kmm)
00009 // @date 11/20/2002 some final comments (ws)
00010 // @date 10/22/2002 implemented various discrete distributions (kmm)
00011 //
00012 //==========================================================================
00013 
00014 
00015 #ifndef __DISTRIB_H_
00016 #define __DISTRIB_H_
00017 
00018 #include "defs.h"
00019 #include "random.h"
00020 
00021 
00031 
00038 SIM_API double uniform(double a, double b, int rng=0);
00039 
00047 SIM_API double exponential(double mean, int rng=0);
00048 
00057 SIM_API double normal(double mean, double stddev, int rng=0);
00058 
00074 SIM_API double truncnormal(double mean, double stddev, int rng=0);
00075 
00102 SIM_API double gamma_d(double alpha, double beta, int rng=0);
00103 
00116 SIM_API double beta(double alpha1, double alpha2, int rng=0);
00117 
00136 SIM_API double erlang_k(unsigned int k, double mean, int rng=0);
00137 
00153 SIM_API double chi_square(unsigned int k, int rng=0);
00154 
00166 SIM_API double student_t(unsigned int i, int rng=0);
00167 
00182 SIM_API double cauchy(double a, double b, int rng=0);
00183 
00193 SIM_API double triang(double a, double b, double c, int rng=0);
00194 
00205 inline double lognormal(double m, double s, int rng=0)
00206 {
00207     return exp(normal(m, s, rng));
00208 }
00209 
00229 SIM_API double weibull(double a, double b, int rng=0);
00230 
00240 SIM_API double pareto_shifted(double a, double b, double c, int rng=0);
00241 
00243 
00253 
00261 SIM_API int intuniform(int a, int b, int rng=0);
00262 
00272 inline int bernoulli(double p, int rng=0)
00273 {
00274     double U = genk_dblrand(rng);
00275     return (p > U) ? 1 : 0;
00276 }
00277 
00290 SIM_API int binomial(int n, double p, int rng=0);
00291 
00304 SIM_API int geometric(double p, int rng=0);
00305 
00318 SIM_API int negbinomial(int n, double p, int rng=0);
00319 
00320 //
00321 // hypergeometric() doesn't work yet
00322 //
00323 // /**
00324 //  * Returns a random integer from the hypergeometric distribution with
00325 //  * parameters a,b and n.
00326 //  *
00327 //  * If you have a+b items (a items of type A and b items of type B)
00328 //  * and you draw n items from them without replication, this function
00329 //  * will return the number of type A items in the drawn set.
00330 //  *
00331 //  * Generation uses inverse transform due to Fishman (see Banks, page 165).
00332 //  *
00333 //  * @param a, b  a,b>0
00334 //  * @param n     0<=n<=a+b
00335 //  * @param rng the underlying random number generator
00336 //  */
00337 // SIM_API int hypergeometric(int a, int b, int n, int rng=0);
00338 
00354 SIM_API int poisson(double lambda, int rng=0);
00355 
00357 
00367 SIM_API double genk_uniform(double gen_nr, double a, double b);
00368 
00372 SIM_API double genk_intuniform(double gen_nr, double a, double b);
00373 
00377 SIM_API double genk_exponential(double gen_nr, double p);
00378 
00382 SIM_API double genk_normal(double gen_nr, double mean, double variance);
00383 
00387 SIM_API double genk_truncnormal(double gen_nr, double mean, double variance);
00389 
00390 
00391 #endif
00392 
00393 

Generated at Mon Jun 16 23:37:31 2003 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001