Commit d734d4a8 authored by Gary E. Miller's avatar Gary E. Miller 💬
Browse files

ntpviz: return 0 as variance of zero or one data items.

No need to crash on empty input.
parent 2e0e5cee
......@@ -57,7 +57,8 @@ def pstdev(data, mu=None):
"""Calculates the population standard deviation."""
n = len(data)
if n < 2:
raise ValueError('variance requires at least two data points')
# variance requires at least two data points
return 0
ss = _ss(data, mu)
pvar = ss/n # the population variance
return pvar**0.5
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment