- Main Page
- Modules
- Classes
- Files
- Directories
- 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
    00111 SIM_API double gamma_d(double alpha, double theta, int rng=0);
    00112
    00125 SIM_API double beta(double alpha1, double alpha2, int rng=0);
    00126
    00145 SIM_API double erlang_k(unsigned int k, double mean, int rng=0);
    00146
    00162 SIM_API double chi_square(unsigned int k, int rng=0);
    00163
    00175 SIM_API double student_t(unsigned int i, int rng=0);
    00176
    00191 SIM_API double cauchy(double a, double b, int rng=0);
    00192
    00202 SIM_API double triang(double a, double b, double c, int rng=0);
    00203
    00215 inline double lognormal(double m, double w, int rng=0)
    00216 {
    00217     return exp(normal(m, w, rng));
    00218 }
    00219
    00239 SIM_API double weibull(double a, double b, int rng=0);
    00240
    00250 SIM_API double pareto_shifted(double a, double b, double c, int rng=0);
    00251
    00253
    00260
    00268 SIM_API int intuniform(int a, int b, int rng=0);
    00269
    00279 inline int bernoulli(double p, int rng=0)
    00280 {
    00281     double U = genk_dblrand(rng);
    00282     return (p > U) ? 1 : 0;
    00283 }
    00284
    00297 SIM_API int binomial(int n, double p, int rng=0);
    00298
    00311 SIM_API int geometric(double p, int rng=0);
    00312
    00325 SIM_API int negbinomial(int n, double p, int rng=0);
    00326
    00327 //
    00328 // hypergeometric() doesn't work yet
    00329 //
    00330 // /**
    00331 //  * Returns a random integer from the hypergeometric distribution with
    00332 //  * parameters a,b and n.
    00333 //  *
    00334 //  * If you have a+b items (a items of type A and b items of type B)
    00335 //  * and you draw n items from them without replication, this function
    00336 //  * will return the number of type A items in the drawn set.
    00337 //  *
    00338 //  * Generation uses inverse transform due to Fishman (see Banks, page 165).
    00339 //  *
    00340 //  * @param a, b  a,b>0
    00341 //  * @param n     0<=n<=a+b
    00342 //  * @param rng the underlying random number generator
    00343 //  */
    00344 // SIM_API int hypergeometric(int a, int b, int n, int rng=0);
    00345
    00361 SIM_API int poisson(double lambda, int rng=0);
    00362
    00364
    00374 SIM_API double genk_uniform(double gen_nr, double a, double b);
    00375
    00379 SIM_API double genk_intuniform(double gen_nr, double a, double b);
    00380
    00384 SIM_API double genk_exponential(double gen_nr, double p);
    00385
    00389 SIM_API double genk_normal(double gen_nr, double mean, double variance);
    00390
    00394 SIM_API double genk_truncnormal(double gen_nr, double mean, double variance);
    00396
    00397
    00398 #endif
    00399
    00400