Skip to content

calculate weighted (mean and SDM) in IDL

At least for now, function wmeanandsig.pro is in /data/psrdata/rmgalprojs

If you create an array of RM and an equal-sized array of sig_RM (with no ∞ sig_RM’s), then:

wmean_and_sdm=wmeanandsig(RM,sig_RM)

will put the weighted mean and weighted sdm into a two-element array  called wmean_and_sdm

(and the way functions work, you can replace the variable that above i call “wmean_and_sdm”, with

a variable of any name you wish)

Right now there is a “driver” program in the same directory, called, “wmeanandsigDRIVER.pro”  .  It

is a module that tests wmeanandsig.pro  .  I used it extensively to do so, to the point where I can now

call wmeanandsig.pro “ready to go”   .  (Luckily the NIST web pages give sample input/output for weighted

mean and for weighted SDM, which I endeavored to match.)

Caution: In 2018 April, I changed the calculation of the weighted SDM.  Previously, we had used the NIST definition, which changed the data weights so as to achieve reduced χ^2 to 1.  (The NIST webpage gave a formula for wgtd SD but did not note that it included this readjustment. )  In 2018 April, I changed the calculation to be

σ^2_wgtdmean = 1 / [ Σ 1/σ^2_j]. Note that this calculation depends entirely on the σ_j’s of the data points, and nothing else (such as deviation from mean).

–Joel
Published inIDL hints

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *