aboutsummaryrefslogtreecommitdiff
path: root/noao/twodspec/multispec/armsr.x
blob: 2f9ce65734c8703aeb2e1400ce8e2010e892c422 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
# ARMSR -- Compute the rms of an array.

real procedure armsr (a, npoints)

real	a[ARB]				# Return rms of this array
int	npoints				# Number of points in the array

int	i
real	avg, rms

begin
	avg = 0.
	rms = 0.
	do i = 1, npoints {
	    avg = avg + a[i]
	    rms = rms + a[i] * a[i]
	}
	rms = sqrt ((npoints * rms - avg * avg) / (npoints * (npoints - 1)))

	return (rms)
end


# ARMSRR -- Compute the vector rms between two real arrays.

real procedure armsrr (a, b, npoints)

real	a[ARB]				# First array
real	b[ARB]				# Second array
int	npoints				# Number of points

int	i
real	residual, rms

begin
	rms = 0.
	do i = 1, npoints {
	    residual = a[i] - b[i]
	    rms = rms + residual ** 2
	}
	rms = sqrt (rms / npoints)

	return (rms)
end