diff --git a/av-variance.c b/av-variance.c index f94ae8b..7a0b8f8 100644 --- a/av-variance.c +++ b/av-variance.c @@ -31,6 +31,10 @@ double sample_variance(double set[], int set_n) { return ss; } +double sample_stddev(double set[], int set_n) { + return sqrt(sample_variance(set, set_n)); +} + int main() { // Some data double d[] = {7, 8, 5, 1, 6, 2}; @@ -49,7 +53,9 @@ int main() { assert(isalmost(sample_variance(d, d_n), 7.766, 0.001)); assert(isalmost(sample_variance(e, e_n), 41.564, 0.001)); - // XXX Stddev + assert(isalmost(sample_stddev(d, d_n), 2.787, 0.001)); + assert(isalmost(sample_stddev(e, e_n), 6.447, 0.001)); + // XXX Range // XXX Mode // XXX Percentile