Commit cf6c7732 authored by Eva Rachel Retuya's avatar Eva Rachel Retuya Committed by Jonathan Cameron

staging: iio: tsl2x7x_core: Fix standard deviation calculation

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>
parent d7ed89d5
...@@ -854,7 +854,7 @@ void tsl2x7x_prox_calculate(int *data, int length, ...@@ -854,7 +854,7 @@ void tsl2x7x_prox_calculate(int *data, int length,
tmp = data[i] - statP->mean; tmp = data[i] - statP->mean;
sample_sum += tmp * tmp; 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