statistics.c
来自「统计方面的程序」· C语言 代码 · 共 34 行
C
34 行
/* 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 + =
减小字号Ctrl + -
显示快捷键?