Commit 2912422b authored by Eva Rachel Retuya's avatar Eva Rachel Retuya Committed by Ben Hutchings

staging: iio: tsl2x7x_core: Fix standard deviation calculation

commit cf6c7732 upstream.

Standard deviation is calculated as the square root of the variance
where variance is the mean of sample_sum and length. Correct the
computation of statP->stddev in accordance to the proper calculation.

Fixes: 3c97c08b ("staging: iio: add TAOS tsl2x7x driver")
Reported-by: default avatarAbhiram Balasubramanian <abhiram@cs.utah.edu>
Signed-off-by: default avatarEva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 7a960cbd
......@@ -849,7 +849,7 @@ void tsl2x7x_prox_calculate(int *data, int length,
tmp = data[i] - statP->mean;
sample_sum += tmp * tmp;
}
statP->stddev = int_sqrt((long)sample_sum)/length;
statP->stddev = int_sqrt((long)sample_sum / length);
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment