Re: 2D Pearson correlation coefficient [message #87404 is a reply to message #87385] |
Fri, 31 January 2014 08:11  |
Phillip Bitzer
Messages: 223 Registered: June 2006
|
Senior Member |
|
|
OK, a few things.
1) That is not a Pearson correlation. Coefficient of determination, maybe.
2) Like Craig said, if you don't know anything about what the weights should be, you should use one. You *could* weight by some knowledge of the errors in the data. We don't know what they are, so we can't tell you what to use. Besides, you're the person closest to the data. You would know best.
3) But, you better have good reason for weighting the data. I strongly suggest you curl up with Bevington's Data Reduction book before you go manipulating the data.
4) Matt told you how to do this. But here goes anyway:
;get some data
m = RANDOMU(seed, 100)
o = RANDOMU(seeed2, 100)
wi1 = 1 ;assuming no points are "more important" than others
wi = (randomn(1l, 100)+2) > 0 ;Just making up *something* for the weights
wi /= TOTAL(wi) ;make sure weights add to one
mMean = MEAN(m)
oMean = MEAN(o)
r2 = TOTAL(wi1*(m-mMean)*(o-oMean))/TOTAL(wi1*(m-mMean)^2)/TOTAL( wi1*(o-oMean)^2)
Of course, you should make this a function, with appropriate parameters, and then try it with arbitrary weights.
|
|
|