Thanks, Ric. You will be the main part of "Show-and-Tell" at NYCJUG tomorrow night.
On Tue, Mar 29, 2016 at 4:54 PM, Ric Sherlock <[email protected]> wrote: > Here's an attempt to come up with weighted versions in the spirit of the > univariate.ijs definitions > > wmean=: +/@[ %~ +/@:* > > wdev=: ] -"_1 _ wmean > > wssdev=: [ +/@:* *:@wdev > > wvar=: (#@-.&0 %~ <:@#@-.&0 * +/)@[ %~ wssdev > > wstddev=: %:@wvar > > > 1 1 0 0 4 1 2 1 0 wstddev 2 3 5 7 11 13 17 19 23 > > 5.82237 > > stddev 2 3 5 7 11 13 17 19 23 > > 7.45729 > > > > On Wed, Mar 30, 2016 at 9:01 AM, Devon McCormick <[email protected]> > wrote: > > > Hi All - > > > > I recently wrote a few basic stat verbs for doing weighted versions of > some > > of the common descriptive statistics. They lack the cohesive elegance of > > the standard versions from the "univariate.ijs" script but I couldn't > > figure out how to replicate it with the weighted versions as I've made > them > > dyadic. > > > > NB.* wtdMean: weighted-mean: x is weights, y is values > > wtdMean=: ([: +/ *) % [: +/ [ > > NB.EG 7r3 = 1 2 3 wtdMean 1 2 3 > > > > NB. wtdSumDev: weighted sum of deviations > > wtdSumDev=: [: +/ [ * ] - [: (+/ % #) ] > > NB.* wtdVar: weighted variance > > wtdVar=: ([: +/ [ * [: *: ] - wtdMean) % ([: ([: (<: % ]) [: # 0 -.~ ]) > [) > > * [: +/ [ > > NB.* wtdSD: weighted standard deviation (biased) > > wtdSD=: [: %: ([: +/ [ * [: *: ] - wtdMean) % [: +/ [ > > NB.* wtdSDunbias: weighted standard deviation (unbiased) > > wtdSDunbias=: [: %: ([: +/ [ * [: *: ] - wtdMean) % ([: ([: (<: % ]) [: > # 0 > > -.~ ]) [) * [: +/ [ > > > > These seem to work OK - see > > > http://www.itl.nist.gov/div898/software/dataplot/refman2/ch2/weightsd.pdf > > - > > but are not as elegantly-interconnected as these: > > > > whereDefined 'stddev' > > c:\...\j64-804\addons\stats\base\univariate.ijs > > stddev > > %:@var > > var > > ssdev % <:@# > > ssdev > > +/@:*:@dev > > dev > > -"_1 _ mean > > mean > > +/ % # > > > > Comments on these are welcome. > > > > -- > > > > Devon McCormick, CFA > > > > Quantitative Consultant > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm -- Devon McCormick, CFA Quantitative Consultant ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
