aboutsummaryrefslogtreecommitdiff
path: root/src/statistics.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2009-12-04 12:00:32 +0100
committerThomas White <taw@physics.org>2009-12-04 12:01:37 +0100
commitba72cc21bb8a36e3fb0ac8e7da69157ae1aed918 (patch)
treeb2f1e905f3368ee1b02acf6ff6a4838645c37833 /src/statistics.c
parent5598807a938f9eea3f3663f770f598b6ece8edbc (diff)
Fix R2 calculation
Diffstat (limited to 'src/statistics.c')
-rw-r--r--src/statistics.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/statistics.c b/src/statistics.c
index 50bfd513..84453ffa 100644
--- a/src/statistics.c
+++ b/src/statistics.c
@@ -59,13 +59,18 @@ double stat_r2(double *obs, double *calc, unsigned int *c, int size,
for ( i=1; i<size; i++ ) {
if ( c[i] > 0 ) {
+
double obsi;
+
obsi = obs[i] / (double)c[i];
- top += pow(fabs(obsi - scale*calc[i]), 2.0);
+ obsi = obsi / scale;
+
+ top += pow(fabs(obsi - calc[i]), 2.0);
bot += pow(obsi, 2.0);
- }
- } /* else reflection not measured so don't worry about it */
+ } /* else reflection not measured so don't worry about it */
+
+ }
return sqrt(top/bot);
}