Replace the way we calculate the standard deviation with the unbiased form
for non-related samples. There are several websites that explain why we should use this form instead of the normal formula to compute the std. dev. (Wikipedia is one of them). Also, ping(8) (where this "new" formula came from) already does it this way so, I'm trying to score some extra points by making both utilities behave the same way. Thanks to wrtstuden@ for the initial clarification.
This commit is contained in:
parent
758cf626b4
commit
25ff2bc882
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: ping6.c,v 1.68 2006/05/07 16:00:18 rpaulo Exp $ */
|
/* $NetBSD: ping6.c,v 1.69 2006/05/18 02:14:22 rpaulo Exp $ */
|
||||||
/* $KAME: ping6.c,v 1.164 2002/11/16 14:05:37 itojun Exp $ */
|
/* $KAME: ping6.c,v 1.164 2002/11/16 14:05:37 itojun Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -77,7 +77,7 @@ static char sccsid[] = "@(#)ping.c 8.1 (Berkeley) 6/5/93";
|
||||||
#else
|
#else
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
__RCSID("$NetBSD: ping6.c,v 1.68 2006/05/07 16:00:18 rpaulo Exp $");
|
__RCSID("$NetBSD: ping6.c,v 1.69 2006/05/18 02:14:22 rpaulo Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -2109,7 +2109,7 @@ summary(void)
|
||||||
/* Only display average to microseconds */
|
/* Only display average to microseconds */
|
||||||
double num = nreceived + nrepeats;
|
double num = nreceived + nrepeats;
|
||||||
double avg = tsum / num;
|
double avg = tsum / num;
|
||||||
double dev = sqrt(tsumsq / num - avg * avg);
|
double dev = sqrt((tsumsq - num * avg * avg) / (num - 1));
|
||||||
(void)printf(
|
(void)printf(
|
||||||
"round-trip min/avg/max/std-dev = %.3f/%.3f/%.3f/%.3f ms\n",
|
"round-trip min/avg/max/std-dev = %.3f/%.3f/%.3f/%.3f ms\n",
|
||||||
tmin, avg, tmax, dev);
|
tmin, avg, tmax, dev);
|
||||||
|
|
Loading…
Reference in New Issue