]>
git.proxmox.com Git - mirror_iproute2.git/blob - netem/normal.c
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
));
25 main(int argc
, char **argv
)
29 double table
[TABLESIZE
+1];
31 for (x
= -10.0; x
< 10.05; x
+= .00005) {
32 i
= rint(TABLESIZE
* normal(x
, 0.0, 1.0));
37 printf("# This is the distribution table for the normal distribution.\n");
38 for (i
= n
= 0; i
< TABLESIZE
; i
+= 4) {
39 int value
= (int) rint(table
[i
]*TABLEFACTOR
);
40 if (value
< SHRT_MIN
) value
= SHRT_MIN
;
41 if (value
> SHRT_MAX
) value
= SHRT_MAX
;