distrib.h

00001 //==========================================================================
00002 // DISTRIB.H
00003 //
00004 //                     OMNeT++/OMNEST
00005 //            Discrete System Simulation in C++
00006 //
00007 // Random variate generation
00008 //
00009 // Authors: Werner Sandmann (ws), Kay Michael Masslow (kmm), Kyeong Soo (Joseph) Kim (jk)
00010 // Documentation, maintenance: Andras Varga
00011 //
00012 // @date 11/26/2002 "doxygenification" (kmm)
00013 // @date 11/20/2002 some final comments (ws)
00014 // @date 10/22/2002 implemented various discrete distributions (kmm)
00015 //
00016 //==========================================================================
00017 
00018 
00019 #ifndef __DISTRIB_H_
00020 #define __DISTRIB_H_
00021 
00022 #include "simkerneldefs.h"
00023 #include "random.h"
00024 #include "simtime.h"
00025 
00026 NAMESPACE_BEGIN
00027 
00033 
00040 SIM_API double uniform(double a, double b, int rng=0);
00041 
00045 inline SimTime uniform(SimTime a, SimTime b, int rng=0) {return uniform(a.dbl(), b.dbl(), rng);}
00046 
00054 SIM_API double exponential(double mean, int rng=0);
00055 
00059 inline SimTime exponential(SimTime mean, int rng=0) {return exponential(mean.dbl(), rng);}
00060 
00069 SIM_API double normal(double mean, double stddev, int rng=0);
00070 
00074 inline SimTime normal(SimTime mean, SimTime stddev, int rng=0) {return normal(mean.dbl(), stddev.dbl(), rng);}
00075 
00091 SIM_API double truncnormal(double mean, double stddev, int rng=0);
00092 
00096 inline SimTime truncnormal(SimTime mean, SimTime stddev, int rng=0) {return truncnormal(mean.dbl(), stddev.dbl(), rng);}
00097 
00133 SIM_API double gamma_d(double alpha, double theta, int rng=0);
00134 
00147 SIM_API double beta(double alpha1, double alpha2, int rng=0);
00148 
00167 SIM_API double erlang_k(unsigned int k, double mean, int rng=0);
00168 
00184 SIM_API double chi_square(unsigned int k, int rng=0);
00185 
00197 SIM_API double student_t(unsigned int i, int rng=0);
00198 
00213 SIM_API double cauchy(double a, double b, int rng=0);
00214 
00224 SIM_API double triang(double a, double b, double c, int rng=0);
00225 
00237 inline double lognormal(double m, double w, int rng=0)
00238 {
00239     return exp(normal(m, w, rng));
00240 }
00241 
00261 SIM_API double weibull(double a, double b, int rng=0);
00262 
00272 SIM_API double pareto_shifted(double a, double b, double c, int rng=0);
00273 
00275 
00281 
00289 SIM_API int intuniform(int a, int b, int rng=0);
00290 
00300 inline int bernoulli(double p, int rng=0)
00301 {
00302     double U = genk_dblrand(rng);
00303     return (p > U) ? 1 : 0;
00304 }
00305 
00318 SIM_API int binomial(int n, double p, int rng=0);
00319 
00332 SIM_API int geometric(double p, int rng=0);
00333 
00346 SIM_API int negbinomial(int n, double p, int rng=0);
00347 
00348 //
00349 // hypergeometric() doesn't work yet
00350 //
00351 // /* *
00352 //  * Returns a random integer from the hypergeometric distribution with
00353 //  * parameters a,b and n.
00354 //  *
00355 //  * If you have a+b items (a items of type A and b items of type B)
00356 //  * and you draw n items from them without replication, this function
00357 //  * will return the number of type A items in the drawn set.
00358 //  *
00359 //  * Generation uses inverse transform due to Fishman (see Banks, page 165).
00360 //  *
00361 //  * @param a, b  a,b>0
00362 //  * @param n     0<=n<=a+b
00363 //  * @param rng the underlying random number generator
00364 //  */
00365 // SIM_API int hypergeometric(int a, int b, int n, int rng=0);
00366 
00382 SIM_API int poisson(double lambda, int rng=0);
00383 
00385 
00386 NAMESPACE_END
00387 
00388 
00389 #endif
00390 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3