summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-05-11 21:58:43 +0200
committertomsmeding <tom.smeding@gmail.com>2017-05-11 21:58:43 +0200
commit4b365556736a5316767fb5adac51b44bde0a077f (patch)
tree300bb42597b34a1d2f2af681ee0155bada39aaae
parent01aed029760fa81caf2f35f7093a22ae729b96b1 (diff)
Add standard error of the mean
-rw-r--r--stddev.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/stddev.cpp b/stddev.cpp
index 5f4c8a7..b652b8a 100644
--- a/stddev.cpp
+++ b/stddev.cpp
@@ -40,8 +40,10 @@ int main(int,char **argv){
total+=(v-s_mean)*(v-s_mean);
}
const double s_stddev=data.size()==1?nan(""):sqrt(total/(data.size()-1));
+ const double s_stderr=s_stddev/sqrt(data.size());
- cout<<"Mean: "<<s_mean<<endl
- <<"Stddev: "<<s_stddev<<endl
+ cout<<"Mean: "<<s_mean<<'\n'
+ <<"Stddev: "<<s_stddev<<'\n'
+ <<"Stderr: "<<s_stderr<<'\n'
<<"Median: "<<s_median<<endl;
}