RMSE - assert 0 <= m <= 16 r = math.sqrt(m) assert...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
#!/usr/bin/env python # ------- # RMSE.py # ------- import math print "RMSE.py" def rmse (a, p) : assert type(a) == tuple assert type(p) == tuple assert len(a) == len(p) i = 0 s = len(a) w = 0 while i != s : v = a[i] - float(p[i]) w += (v * v) i += 1 assert type(w) is float assert 0 <= w <= (16 * s) m = (w / s) assert type(m) is float
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: assert 0 <= m <= 16 r = math.sqrt(m) assert type(r) is float assert 0 <= r <= 4 return r assert str(rmse((3, 3, 3), (3, 3, 3))) == "0.0" assert str(rmse((1, 1, 1, 1), (5, 5, 5, 5))) == "4.0" assert str(rmse((5, 3, 2, 4, 5), (2, 4, 3, 1, 2))) == "2.40831891576" print "Done."...
View Full Document

This note was uploaded on 04/05/2010 for the course CS 373 taught by Professor Downing,glennp during the Fall '08 term at University of Texas.

Ask a homework question - tutors are online