summaryrefslogtreecommitdiff
path: root/apps/JAWS/clients/WebSTONE/src/statistics.c
blob: c07d50059d71c1a9df2c753446b7c996d9933d5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**************************************************************************
 *									  *
 * 		 Copyright (C) 1995 Silicon Graphics, Inc.		  *
 *									  *
 *  These coded instructions, statements, and computer programs were	  *
 *  developed by SGI for public use.  If any changes are made to this code*
 *  please try to get the changes back to the author.  Feel free to make  *
 *  modifications and changes to the code and release it.		  *
 *									  *
 **************************************************************************/

#include <math.h>
#include <stdlib.h>
#include "sysdep.h"
#include "bench.h"


double
mean(const double sum, const int n)
{
  if (n)
    {
      return(sum / n);
    }
  else
    {
      return(0);
    }
}


double
variance(const double sum, const double sumofsquares, const int n)
{
	double	meanofsum;

	meanofsum = mean(sum, n);

	return (mean(sumofsquares,n) - (meanofsum * meanofsum));
}


double
stddev(const double sum, const double sumofsquares, const int n)
{
	return(sqrt(fabs(variance(sum, sumofsquares, n))));
}