2 * Paretoormal distribution table generator
4 * This distribution is simply .25*normal + .75*pareto; a combination
5 * which seems to match experimentally observed distributions reasonably
6 * well, but is computationally easy to handle.
7 * The entries represent a scaled inverse of the cumulative distribution
10 * Taken from the uncopyrighted NISTnet code.
20 #include <linux/types.h>
21 #include <linux/pkt_sched.h>
23 #define TABLESIZE 16384
24 #define TABLEFACTOR NETEM_DIST_SCALE
27 normal(double x, double mu, double sigma)
29 return .5 + .5*erf((x-mu)/(sqrt(2.0)*sigma));
32 static const double a=3.0;
40 dvalue = (double)i/(double)65536;
41 dvalue = 1.0/pow(dvalue, 1.0/a);
43 dvalue *= (4.0/3.0)*(double)TABLEFACTOR;
46 return (int)rint(dvalue);
50 main(int argc, char **argv)
54 double table[TABLESIZE+1];
56 for (x = -10.0; x < 10.05; x += .00005) {
57 i = rint(TABLESIZE*normal(x, 0.0, 1.0));
61 "# This is the distribution table for the paretonormal distribution.\n"
64 for (i = n = 0; i < TABLESIZE; i += 4) {
65 int normvalue, parvalue, value;
67 normvalue = (int) rint(table[i]*TABLEFACTOR);
68 parvalue = paretovalue(i);
70 value = (normvalue+3*parvalue)/4;
71 if (value < SHRT_MIN) value = SHRT_MIN;
72 if (value > SHRT_MAX) value = SHRT_MAX;