comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Question about MOMENT
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Question about MOMENT [message #4786] Wed, 26 July 1995 00:00
ECSPRS is currently offline  ECSPRS
Messages: 6
Registered: November 1994
Junior Member
Hi again.
There's something in the MOMENT function I don't think fits with the online
documentation. When calculating the variance the online help defines it as;

1 [ N-1 1 [ N-1 ] ]
Variance = ---- [Sigma (Xi-Xbar)^2 - --- [ Sigma (Xi-Xbar) ]^2 ]
N-1 [ i=0 N [ i=0 ] ]

where Xi is data points, Xbar is the mean, N number of points.
Now in the function code of MOMENT.PRO (in \IDL40\LIB) variance is calculated
the following way;

var1 = total((x - mean)^2) / (nx-1.0)
var2 = (total((x-mean)^2) - ((total((x-mean)))^2)/nx)/(nx-1.0)
var = (var1 + var2)/2.0
sdev = sqrt(var) ; standard deviation

Now var1 is obviously the first term in the above equation. What I couldn't
figure was why that term also appears in var2, along with the second term,
until I saw the third line which adds and then divides by 2 to get var. So to
rewrite the IDL code as equations that means;


var = Sigma(Xi - Xbar)^2 Sigma(Xi - Xbar)^2 (Sigma(Xi - Xbar))^2
------------------ + ------------------- - --------------------
2(N-1) 2(N-1) 2N(N-1)

(dropping all the sigma extra bits)
So, point (1), the second term has now been divided by a factor of 2, unlike
what appears in the documentation, and point (2) why go to all the
computational effort of calculating term 1 twice just so you can halve it and
add them together? The rest of the MOMENT code doesn't show any other use for
individual var1 and var2 parts. As far as I can see lines 1 and 3 of the above
code should be dropped and var2 is the result we're after.
Comments, flames, anyone?
Paul
[Message index]
 
Read Message
Previous Topic: MAP_SET and Polar Stereographic Projections
Next Topic: Reading ASCII

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 04:51:29 PDT 2025

Total time taken to generate the page: 0.32356 seconds