Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

distrib.h

00001 //==========================================================================
00002 // DISTRIB.H
00003 //
00004 //                     OMNeT++/OMNEST
00005 //            Discrete System Simulation in C++
00006 //
00007 // Random variate generation
00008 //
00009 // @author Werner Sandmann (ws), Kay Michael Masslow (kmm)
00010 //
00011 // @date 11/26/2002 "doxygenification" (kmm)
00012 // @date 11/20/2002 some final comments (ws)
00013 // @date 10/22/2002 implemented various discrete distributions (kmm)
00014 //
00015 //==========================================================================
00016 
00017 
00018 #ifndef __DISTRIB_H_
00019 #define __DISTRIB_H_
00020 
00021 #include "defs.h"
00022 #include "random.h"
00023 
00024 
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 
00206 inline double lognormal(double m, double w, int rng=0)
00207 {
00208     return exp(normal(m, w, rng));
00209 }
00210 
00230 SIM_API double weibull(double a, double b, int rng=0);
00231 
00241 SIM_API double pareto_shifted(double a, double b, double c, int rng=0);
00242 
00244 
00251 
00259 SIM_API int intuniform(int a, int b, int rng=0);
00260 
00270 inline int bernoulli(double p, int rng=0)
00271 {
00272     double U = genk_dblrand(rng);
00273     return (p > U) ? 1 : 0;
00274 }
00275 
00288 SIM_API int binomial(int n, double p, int rng=0);
00289 
00302 SIM_API int geometric(double p, int rng=0);
00303 
00316 SIM_API int negbinomial(int n, double p, int rng=0);
00317 
00318 //
00319 // hypergeometric() doesn't work yet
00320 //
00321 // /**
00322 //  * Returns a random integer from the hypergeometric distribution with
00323 //  * parameters a,b and n.
00324 //  *
00325 //  * If you have a+b items (a items of type A and b items of type B)
00326 //  * and you draw n items from them without replication, this function
00327 //  * will return the number of type A items in the drawn set.
00328 //  *
00329 //  * Generation uses inverse transform due to Fishman (see Banks, page 165).
00330 //  *
00331 //  * @param a, b  a,b>0
00332 //  * @param n     0<=n<=a+b
00333 //  * @param rng the underlying random number generator
00334 //  */
00335 // SIM_API int hypergeometric(int a, int b, int n, int rng=0);
00336 
00352 SIM_API int poisson(double lambda, int rng=0);
00353 
00355 
00365 SIM_API double genk_uniform(double gen_nr, double a, double b);
00366 
00370 SIM_API double genk_intuniform(double gen_nr, double a, double b);
00371 
00375 SIM_API double genk_exponential(double gen_nr, double p);
00376 
00380 SIM_API double genk_normal(double gen_nr, double mean, double variance);
00381 
00385 SIM_API double genk_truncnormal(double gen_nr, double mean, double variance);
00387 
00388 
00389 #endif
00390 
00391 

Generated on Thu Jan 12 16:01:40 2006 for OMNeT++/OMNEST Simulation Library by  doxygen 1.4.1