jackscott / python-statlib

Exported from google.code, needed to get this crusty code working in a modern world
https://archive.org/web/
Other
0 stars 0 forks source link

error handling on stdev and skew for single value #16

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. statlib.stat.stdev(1) or statlib.stat.skew(1)

What is the expected output? What do you see instead?
raises error "float division by zero", because dividing by "n-1" for n=1. I 
would expect a 0 or NaN as a return

an error handle would be really nice here. Thank you.

Original issue reported on code.google.com by theta-de...@gmx.de on 16 Sep 2010 at 11:33

GoogleCodeExporter commented 8 years ago
It simply happened to me because I hand over lists of unknown, various lengths, 
and sometimes they contain only one single value. That is how I came across 
this error.

Original comment by theta-de...@gmx.de on 16 Sep 2010 at 11:35

GoogleCodeExporter commented 8 years ago
Just about any function in statistics will fail or produce wrong values if the 
input is not checked for validity. You can just wrap the function into an error 
checker as well.

Original comment by istvan.a...@gmail.com on 16 Sep 2010 at 11:41