aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/inlfit/inrms.gx
blob: a2c5015bc9be96979f4644a6b182eb9ad45b8fd6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# IN_RMS -- Compute rms of points which have a non-zero weight.

PIXEL procedure in_rms$t (y, fit, wts, npts)

PIXEL	y[npts]		# function
PIXEL	fit[npts]	# fit
PIXEL	wts[npts]	# weights
int	npts		# number of points

int	i, ndata
PIXEL	resid, rms

begin
	rms = PIXEL (0.0)
	ndata = 0

	do i = 1, npts {
	    if (wts[i] == PIXEL (0.0))
		next
	    resid = y[i] - fit[i]
	    rms = rms + resid * resid
	    ndata = ndata + 1
	}

	if (ndata > 0)
	    rms = sqrt (rms / ndata)
	else
	    rms = PIXEL (0.0)

	return (rms)
end