Better get on implementing this in Ruby: https://github.com/graphite-project/graphite-web/blob/master/webapp/graphite/render/functions.py