Not quite sure what these do, but they look promising, especially the second.
PHP Code:
updateratingdeviation(float, float) - returns float - old deviation, time of last spar, returns new deviation
updateratings(obj) - returns object - updates an array of {rating1,ratingdeviation1, rating2,ratingdeviation2, ...}, init them at 1500 and 350