From 9b8a97db9ec4b795e29e72289005fbc58484ebeb Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 9 Apr 2024 15:14:35 +0200 Subject: Adding upstream version 6.8.0. Signed-off-by: Daniel Baumann --- netem/stats.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 netem/stats.c (limited to 'netem/stats.c') diff --git a/netem/stats.c b/netem/stats.c new file mode 100644 index 0000000..99c4fee --- /dev/null +++ b/netem/stats.c @@ -0,0 +1,78 @@ +/* SPDX-License-Identifier: NIST-PD */ +/* + * Experimental data distribution table generator + * Taken from the uncopyrighted NISTnet code (public domain). + * + * Rread in a series of "random" data values, either + * experimentally or generated from some probability distribution. + * From this, report statistics. + */ + +#include +#include +#include +#include +#include +#include + +void +stats(FILE *fp) +{ + struct stat info; + double *x; + int limit; + int n=0, i; + double mu=0.0, sigma=0.0, sumsquare=0.0, sum=0.0, top=0.0, rho=0.0; + double sigma2=0.0; + + fstat(fileno(fp), &info); + if (info.st_size > 0) { + limit = 2*info.st_size/sizeof(double); /* @@ approximate */ + } else { + limit = 10000; + } + x = (double *)malloc(limit*sizeof(double)); + + for (i=0; i 1) { + fp = fopen(argv[1], "r"); + if (!fp) { + perror(argv[1]); + exit(1); + } + } else { + fp = stdin; + } + stats(fp); + return 0; +} -- cgit v1.2.3