Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ukma!rutgers!att!ihlpl!kat3 From: kat3@ihlpl.ATT.COM (Craig) Newsgroups: comp.lang.c Subject: standard deviation Message-ID: <9847@ihlpl.ATT.COM> Date: 25 Mar 89 19:16:02 GMT Reply-To: kat3@ihlpl.UUCP (Craig,R.J.) Distribution: usa Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 191 There are two issues associated with the computation of the standard deviation which have been brought up in the provious postings. The first of these is which of the following is the "correct" estimator for the standard deviation from a sample: x[0], x[1], ..., x[N-1] of size N. mean = 0.0; for (i=0; i extern char *malloc(); main(argc, argv) int argc; char **argv; { double *x, std_dev, sum, mean, sqrt(); int i, N; FILE *fopen(), *fp; if (argc != 2) { printf("std: requires an input file!\n"); exit(1); } else if ((fp = fopen(argv[1], "r")) == NULL) { printf("std: cannot open %s\n", argv[1]); exit(1); } fscanf(fp, "%d", &N); x = (double *) malloc(N*sizeof(double)); if (x == NULL) { printf("std: not sufficient memory!\n"); exit(1); } for (i=0; i extern char *malloc(); main(argc, argv) int argc; char **argv; { double *x, std_dev, xsum, xsq, sqrt(); int i, N; FILE *fopen(), *fp; if (argc != 2) { printf("std: requires an input file!\n"); exit(1); } else if ((fp = fopen(argv[1], "r")) == NULL) { printf("std: cannot open %s\n", argv[1]); exit(1); } fscanf(fp, "%d", &N); x = (double *) malloc(N*sizeof(double)); if (x == NULL) { printf("std: not sufficient memory!\n"); exit(1); } for (i=0; i