diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /noao/astutil/pdm/pdmstats.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
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 |