[PATCH] Fix standard deviation calculation
authorJens Axboe <jens.axboe@oracle.com>
Wed, 10 Jan 2007 14:39:51 +0000 (15:39 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 10 Jan 2007 14:39:51 +0000 (15:39 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
stat.c

diff --git a/stat.c b/stat.c
index a84f28a58edf4069091bccf25ffc9801426ce3fb..6e7c23570bf88836e8b1911aa7719c1a1e8581ef 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -298,11 +298,11 @@ static int calc_lat(struct io_stat *is, unsigned long *min, unsigned long *max,
        if (n <= 1.0)
                return 1;
 
-       o = (double) is->val_sq - ((*mean * *mean) / n);
+       o = ((double) is->val_sq - (*mean * is->val)) / n;
        if (o < 0.0)
                *dev = -1.0;
        else
-               *dev = sqrt(o / (n - 1.0));
+               *dev = sqrt(o);
 
        return 1;
 }