From 6264ff6e0ac13fcc22afcb4ce9f98a920444a92c Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 12 Jul 2010 10:06:47 +0200 Subject: compare_hkl: Add Pearson correlation --- src/statistics.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/statistics.c') diff --git a/src/statistics.c b/src/statistics.c index da3d95c4..f3fb21c0 100644 --- a/src/statistics.c +++ b/src/statistics.c @@ -18,6 +18,7 @@ #include #include #include +#include #include "statistics.h" #include "utils.h" @@ -249,3 +250,38 @@ double stat_r2(const double *ref1, const unsigned int *c1, { return r_minimised(ref1, c1, ref2, c2, scalep, R_2); } + + +double stat_pearson(const double *ref1, const unsigned int *c1, + const double *ref2, const unsigned int *c2) +{ + double vec1[4096]; + double vec2[4096]; + signed int h, k, l; + int i = 0; + + for ( l=-INDMAX; l0.0) && (i2>0.0) ) { + vec1[i] = sqrt(i1 / (double)c1s); + vec2[i] = sqrt(i2 / (double)c2s); + i++; + } + + } + } + } + + return gsl_stats_correlation(vec1, 1, vec2, 1, i); +} -- cgit v1.2.3