📄 statistics.c
字号:
/* statistics.c -- general purpose statistics functions * * Author: Jon Hamkins * Last Revised: Tue Jan 30 09:51:45 PST 2001 *//* mean of a vector a[b..e] */doublemean(double a[], int b, int e){ double m = 0.; int i; for (i=b; i<=e; i++) m += a[i]; return(m/(double)(e-b+1));} /* variance of a vector a[b..e] *//* Note: this function normalizes by N-1 where N is the array length. * This gives the best unbiased estimate of the variance if the array * elements are samples from a normal distribution. If the array * elements are the possible values in an equal-probability * distribution, one should normalize by N instead. */double var(double a[], int b, int e){ double v = 0., m; int i; m = mean(a,b,e); for (i=b; i<=e; i++) v += (a[i]-m)*(a[i]-m); return(v/(double)(e-b));}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -