2 * Normal distribution table generator
3 * Taken from the uncopyrighted NISTnet code.
11 #include <linux/types.h>
12 #include <linux/pkt_sched.h>
14 #define TABLESIZE 16384
15 #define TABLEFACTOR NETEM_DIST_SCALE
18 normal(double x, double mu, double sigma)
20 return .5 + .5*erf((x-mu)/(sqrt(2.0)*sigma));
24 main(int argc, char **argv)
29 table = calloc(sizeof(double), TABLESIZE+1);
31 fprintf(stderr, "Not enough memory\n");
36 for (x = -10.0; x < 10.05; x += .00005) {
37 i = (int)rint(TABLESIZE*normal(x, 0.0, 1.0));
42 printf("# This is the distribution table for the normal distribution.\n");
43 for (i = n = 0; i < TABLESIZE; i += 4) {
44 int value = (int) rint(table[i]*TABLEFACTOR);
45 if (value < SHRT_MIN) value = SHRT_MIN;
46 if (value > SHRT_MAX) value = SHRT_MAX;