From: octo Date: Tue, 16 May 2006 19:10:46 +0000 (+0000) Subject: Correct the calculation of the standard deviation. X-Git-Tag: liboping-0.2.0~5 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=e1ad84e31e8c7e39b17bcf7d1c1a5c281e392f98;p=liboping.git Correct the calculation of the standard deviation. --- diff --git a/src/oping.c b/src/oping.c index 37f64b2..5940001 100644 --- a/src/oping.c +++ b/src/oping.c @@ -401,7 +401,8 @@ int main (int argc, char **argv) num_total = (double) context->req_rcvd; average = context->latency_total / num_total; - deviation = sqrt (context->latency_total_square - (num_total * average * average)); + deviation = sqrt (((num_total * context->latency_total_square) - (context->latency_total * context->latency_total)) + / (num_total * (num_total - 1.0))); printf ("rtt min/avg/max/sdev = %.3f/%.3f/%.3f/%.3f ms\n", context->latency_min,