diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /noao/astutil/pdm/pdmstats.x | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'noao/astutil/pdm/pdmstats.x')
-rw-r--r-- | noao/astutil/pdm/pdmstats.x | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/noao/astutil/pdm/pdmstats.x b/noao/astutil/pdm/pdmstats.x new file mode 100644 index 00000000..aeabacaa --- /dev/null +++ b/noao/astutil/pdm/pdmstats.x @@ -0,0 +1,37 @@ +include <mach.h> +include <ctype.h> +include <error.h> +include "pdm.h" + +# PDM_STATISTICS -- Calculate the sum of squares and the variance of the data. + +procedure pdm_statistics (pdmp) + +pointer pdmp # pointer to PDM data structure + +int npt, i, j +double var, sumx2, sum + +begin + npt = PDM_NPT(pdmp) + + # Calculate the sum of squares and the variance of the data. + sumx2 = 0.0 + sum = 0.0 + j = 0 + + do i = 1, npt { + if (PDM_INUSE(pdmp,i) == 1) { + sumx2 = sumx2 + PDM_DY(pdmp,i)**2 # Sum of squares. + sum = sum + PDM_DY(pdmp,i) + j = j + 1 + } + } + + if (j != 1) + var = (sumx2 - sum**2/double(j))/double(j - 1) # Variance. + + # Put these two values in the data structure. + PDM_SUMSQ(pdmp) = sumx2 + PDM_DVAR(pdmp) = var +end |