diff --git a/Makefile b/Makefile index 9ed1d75..9c32d0a 100644 --- a/Makefile +++ b/Makefile @@ -60,3 +60,6 @@ mtrace-test.txt: mtrace-test.trace uiowa-threads-example: uiowa-threads.o uiowa-threads-example.c $(CC) $(CFLAGS) -o $@ $^ + +av-variance: av-variance.c + $(CC) $(CFLAGS) -o $@ $< -lm diff --git a/av-variance.c b/av-variance.c index 7bfabd0..f94ae8b 100644 --- a/av-variance.c +++ b/av-variance.c @@ -17,6 +17,20 @@ bool isalmost(double x, double c, double epsilon) { return fabs(x-c) < epsilon; } +double sample_variance(double set[], int set_n) { + double m = mean(set, set_n); + + double ss = 0.0; + for (int i=0; i