stdev() flag

34 views
Skip to first unread message

aya...@gmail.com

unread,
Jan 8, 2015, 10:17:15 AM1/8/15
to jstat-...@googlegroups.com
Hi,

I think there is an error in the docs for the stdev() Vector function.

Running the function with and without the flag set returns the following:

> jStat.jStat.stdev([155, 160, 152, 168, 172, 169, 172, 165, 158, 159, 201, 219, 250, 300, 264, 223, 189, 199, 208, 187, 147, 250, 270, 223, 217, 197, 184, 158, 199, 201, 223, 217, 197, 219, 186, 164, 151, 192, 136, 207, 254, 213, 198, 203, 196, 165, 160, 277, 265, 116]);
39.26079469394373

> jStat.jStat.stdev([155, 160, 152, 168, 172, 169, 172, 165, 158, 159, 201, 219, 250, 300, 264, 223, 189, 199, 208, 187, 147, 250, 270, 223, 217, 197, 184, 158, 199, 201, 223, 217, 197, 219, 186, 164, 151, 192, 136, 207, 254, 213, 198, 203, 196, 165, 160, 277, 265, 116], false);
39.26079469394373

> jStat.jStat.stdev([155, 160, 152, 168, 172, 169, 172, 165, 158, 159, 201, 219, 250, 300, 264, 223, 189, 199, 208, 187, 147, 250, 270, 223, 217, 197, 184, 158, 199, 201, 223, 217, 197, 219, 186, 164, 151, 192, 136, 207, 254, 213, 198, 203, 196, 165, 160, 277, 265, 116], true);
39.65939166122919

It looks like passing in 'true' as the flag returns the *sample* standard deviation and by default, the function returns the *population* standard deviation.

Am I looking at this cross-eyed?

Thanks,
Andy

James Gibson

unread,
Jan 8, 2015, 7:12:24 PM1/8/15
to jstat-...@googlegroups.com
Hi Andy,

Looks like you're right. The 'population' estimator should be dividing by N, and the 'sample' estimator should be dividing by N-1, so the 'sample' estimator should always be higher. This is actually reflected correctly in the test file; the docs are wrong. 

Sorry about that; I'm pretty sure I actually wrote that doc... my mistake! We'll have a fix soon.

Thanks for reporting the problem!
-james

--
You received this message because you are subscribed to the Google Groups "jStat" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jstat-discus...@googlegroups.com.
To post to this group, send email to jstat-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jstat-discuss/97292734-19fb-4f59-a37a-e48cda44ae6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages