simple-statistics icon indicating copy to clipboard operation
simple-statistics copied to clipboard

feat: standardError

Open Yomguithereal opened this issue 8 years ago • 6 comments

Adding the standardError function to the library.

Some interrogations:

  • What should we return when the list has only 1 element? 0 as done now?
  • What should we do with an empty list? Throw? (Note that this case is not addressed with the standardDeviation function either).
  • Should we also add sampleStandardError with Bessel's correction?

Note that I can add some unit tests to reflect our choices on the first two questions.

Yomguithereal avatar Oct 16 '17 21:10 Yomguithereal

Related to #203.

Yomguithereal avatar Oct 16 '17 21:10 Yomguithereal

Nobody wants standard error :(. Sadness fills my heart.

Yomguithereal avatar Nov 06 '17 16:11 Yomguithereal

Bump?

Yomguithereal avatar Mar 20 '18 21:03 Yomguithereal

For your first two interrogations,

What should we return when the list has only 1 element? 0 as done now?
What should we do with an empty list? Throw? (Note that this case is not addressed with the standardDeviation function either).

I vote for both we return nan . I'd have to review, but I believe in either case we'll have degrees of freedom for our estimates <= 0. This also mirrors how both R and scipy handle such cases.

scipy.stats.sem also has a policy for handling nan returns, (e.g. throw or return nan) - maybe you could add something similar?

jwilber avatar Apr 23 '18 21:04 jwilber

@Yomguithereal @jwilber I've rebased and cleaned up this branch - sorry, wasn't very familiar with standard error the concept, the delay on this one is 😢.

The current state of the branch is that throws with [] input, like other methods, and returns 0 on single-element input, which seems like the right approach given that std_dev / sqrt(length) returns 0 naively. If that's good for you folks, I'll merge and release with this (thanks @Yomguithereal and sorry for the epic delay :/)

tmcw avatar Jun 14 '20 00:06 tmcw

@tmcw so everything's alright with current code? Do you want me to add TS definition file?

Yomguithereal avatar Jun 15 '20 07:06 Yomguithereal