diff options
author | rsiddharth <s@ricketyspace.net> | 2020-04-17 21:02:35 -0400 |
---|---|---|
committer | rsiddharth <s@ricketyspace.net> | 2020-04-17 21:02:35 -0400 |
commit | b924fc2f66d46ee10aa3b800a6521d3940919f9f (patch) | |
tree | 130a19d8211874e3ba01203af0d2332506106be4 /nserver/src/stats.h | |
parent | 1bab8e87d3875f672e7c36d10aea9e05f657c664 (diff) |
nserver/ -> ./
Diffstat (limited to 'nserver/src/stats.h')
-rw-r--r-- | nserver/src/stats.h | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/nserver/src/stats.h b/nserver/src/stats.h deleted file mode 100644 index f9e5d7a..0000000 --- a/nserver/src/stats.h +++ /dev/null @@ -1,47 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause */ -/* - * Copyright © 2010, Zed A. Shaw. - * Copyright © 2020 rsiddharth <s@ricketyspace.net> - */ - -#ifndef stats_h -#define stats_h - -#include <math.h> -#include <stdlib.h> -#include <bstrlib.h> -#include <dbg.h> - -typedef struct Stats { - double sum; - double sumsq; - unsigned long n; - double min; - double max; -} Stats; - -Stats *Stats_recreate(double sum, double sumsq, unsigned long n, - double min, double max); - -Stats *Stats_create(); - -void Stats_sample(Stats *st, double s); - -char *Stats_dump(Stats *st); - -char *Stats_stringify(Stats *st); - -Stats *Stats_unstringify(char *st_str); - -static inline double Stats_mean(Stats *st) -{ - return st->sum / st->n; -} - -static inline double Stats_stddev(Stats *st) -{ - return sqrt((st->sumsq - (st->sum * st->sum / st->n)) / - (st->n - 1)); -} - -#endif |