aboutsummaryrefslogtreecommitdiff
path: root/src/statistics.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2009-12-01 15:48:00 +0100
committerThomas White <taw@physics.org>2009-12-01 15:48:00 +0100
commit1709a699e5d31da433798b8a312e2a7098c5fa37 (patch)
treec2ac81469d418d55f2166ea4780ebf48bd57cf06 /src/statistics.c
parent7025bd8293fcf72f7287ee9eee661708aad2895c (diff)
Various improvements
Diffstat (limited to 'src/statistics.c')
-rw-r--r--src/statistics.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/statistics.c b/src/statistics.c
index 9219b069..50bfd513 100644
--- a/src/statistics.c
+++ b/src/statistics.c
@@ -29,7 +29,8 @@ static double stat_scale_intensity(double *obs, double *calc, unsigned int *c,
double bot = 0.0;
int i;
- for ( i=0; i<size; i++ ) {
+ /* Start from i=1 -> skip central beam */
+ for ( i=1; i<size; i++ ) {
if ( c[i] > 0 ) {
double obsi;
@@ -54,16 +55,17 @@ double stat_r2(double *obs, double *calc, unsigned int *c, int size,
scale = stat_scale_intensity(obs, calc, c, size);
*scalep = scale;
- for ( i=0; i<size; i++ ) {
+ /* Start from i=1 -> skip central beam */
+ for ( i=1; i<size; i++ ) {
if ( c[i] > 0 ) {
double obsi;
obsi = obs[i] / (double)c[i];
- top += fabs(obsi/scale - calc[i]);
- bot += obsi/scale;
+ top += pow(fabs(obsi - scale*calc[i]), 2.0);
+ bot += pow(obsi, 2.0);
}
} /* else reflection not measured so don't worry about it */
- return top/bot;
+ return sqrt(top/bot);
}