Module: xenomai-3
Branch: next
Commit: 50aa0a9aae828ecedaf1d5ff6f875755fe32a9b5
URL:    
http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=50aa0a9aae828ecedaf1d5ff6f875755fe32a9b5

Author: Jorge Ramirez-Ortiz <j...@xenomai.org>
Date:   Sun Oct 26 10:47:45 2014 -0400

lib/analogy: use stddev to calculate stddev_of_mean

---

 lib/analogy/math.c |   12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/lib/analogy/math.c b/lib/analogy/math.c
index c0e2f60..1679ecd 100644
--- a/lib/analogy/math.c
+++ b/lib/analogy/math.c
@@ -449,16 +449,8 @@ void a4l_math_stddev(double *pstddev, double mean, double 
*val, unsigned nr)
  */
 void a4l_math_stddev_of_mean(double *pstddevm, double mean, double *val, 
unsigned nr)
 {
-       double sum, sum_sq;
-       int i;
-
-       for (sum = 0, sum_sq = 0, i = 0; i < nr; i++) {
-               double x = val[i] - mean;
-               sum_sq += x * x;
-               sum += x;
-       }
-
-       *pstddevm = sqrt(((sum_sq - (sum * sum) / nr) / (nr - 1)) / nr);
+       a4l_math_stddev(pstddevm, mean, val, nr);
+       *pstddevm = *pstddevm / sqrt(nr); 
 }
 
 


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://www.xenomai.org/mailman/listinfo/xenomai-git

Reply via email to