Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stdev()'s standard deviation calculation is not correct #986

Closed
Dieterbe opened this issue Oct 10, 2014 · 6 comments
Closed

stdev()'s standard deviation calculation is not correct #986

Dieterbe opened this issue Oct 10, 2014 · 6 comments
Labels

Comments

@Dieterbe
Copy link
Contributor

maybe I'm missing something, but the formula used at https://github.com/graphite-project/graphite-web/blob/master/webapp/graphite/render/functions.py#L2054 seems incorrect
here's a simple test program to verify:

#!/usr/bin/env python2
import math

values = [5, 8, 7, 10]

s = sum(values)
print "sum", s

mean = s / len(values)
print "mean", mean

print "traditional:"
print math.sqrt(sum([(i - mean) ** 2 for i in values]) / len(values))

print "graphite:"
print math.sqrt(len(values) * sum([i ** 2 for i in values]) - s ** 2) / len(values)

output:

sum 30
mean 7
traditional:
1.73205080757
graphite:
1.80277563773
@Dieterbe
Copy link
Contributor Author

i was trying to rewrite this algorithm and tune it, but then i wondered:
would it make sense to start doing more of this math using standard packages like numpy? might be faster too if numpy uses C modules.

@obfuscurity
Copy link
Member

We've had conversations around numpy in the past but rejected the idea due to the dependencies.

@drawks
Copy link
Member

drawks commented Oct 13, 2014

I wouldn't call it a consensus, but... The last in depth conversation WRT inclusion of numpy seemed to conclude with wanting to modularize the rendering functions first and then it would be easy to provide numpy based functions for systems where the dependency isn't a problem. FWIW numpy is much faster than the inbuilt pure-python solutions for several of the core functions.

@pcn
Copy link

pcn commented Oct 13, 2014

Has anyone taken a stab at the modularization?

@drawks
Copy link
Member

drawks commented Oct 13, 2014

@pcn I just added #988 to the milestones for 1.0.0

@stale
Copy link

stale bot commented Apr 14, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 14, 2020
@stale stale bot closed this as completed Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants