aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2018-08-31 20:32:06 +0200
committerThomas White <taw@physics.org>2018-08-31 20:32:06 +0200
commit51ee50053c9658d75ebd6df229b054a49d040c7d (patch)
treedfe25085d27fa1cc7ca6f22b9629ff514a84cd2f /src
parentcf6d943f2d01e956e2735c98b610906df9273733 (diff)
CC fixes
Diffstat (limited to 'src')
-rw-r--r--src/rejection.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/rejection.c b/src/rejection.c
index b4e16f17..b6cb098c 100644
--- a/src/rejection.c
+++ b/src/rejection.c
@@ -102,7 +102,7 @@ static double calculate_cchalf(RefList *template, RefList *full,
double all_sum_mean = 0.0;
double all_sumsq_mean = 0.0;
double all_sum_var = 0.0;
- double sig2E, sig2Y;
+ double hsig2E, sig2Y;
int n = 0;
signed int oh = 0;
signed int ok = 0;
@@ -149,12 +149,15 @@ static double calculate_cchalf(RefList *template, RefList *full,
refl_sum += Ii;
refl_sumsq += Ii * Ii;
+ nc++;
}
- refl_mean = refl_sum / c->n_contrib;
- bcorr = c->n_contrib / (c->n_contrib - 1);
- refl_var = (refl_sumsq - refl_sum*refl_sum)*bcorr;
+ if ( nc < 2 ) continue;
+
+ refl_mean = refl_sum / nc;
+ refl_var = (refl_sumsq/nc - refl_mean*refl_mean);
+ refl_var *= nc/(nc-1.0);
all_sum_mean += refl_mean;
all_sumsq_mean += refl_mean*refl_mean;
@@ -163,13 +166,14 @@ static double calculate_cchalf(RefList *template, RefList *full,
}
- sig2E = all_sum_var / n;
- sig2Y = (all_sumsq_mean - all_sum_mean*all_sum_mean)*n/(n-1);
+ hsig2E = all_sum_var / n;
+ sig2Y = (all_sumsq_mean/n - all_sum_mean*all_sum_mean/(n*n));
+ sig2Y *= n/(n-1.0);
if ( pnref != NULL ) {
*pnref = n;
}
- return (sig2Y - 0.5*sig2E) / (sig2Y + 0.5*sig2E);
+ return (sig2Y - hsig2E) / (sig2Y + hsig2E);
}