Expanding the longer unutbu answer above, it can automatically generate a masked array of points. Since your estimates for the values ββare consistent, each pass goes through a cycle, so estimates for each value need to be calculated only once. Here's a slightly inelegant way of doing this using the 6x10 array as an example, before and after your ratings.
>>> import numpy >>> values = numpy.random.randint(6, size=(6,10)) >>> values array([[4, 5, 1, 2, 1, 4, 0, 1, 0, 4], [2, 5, 2, 2, 3, 1, 3, 5, 3, 1], [3, 3, 5, 4, 2, 1, 4, 0, 0, 1], [2, 4, 0, 0, 4, 1, 4, 0, 1, 0], [0, 4, 1, 2, 0, 3, 3, 5, 0, 1], [2, 3, 3, 4, 0, 1, 1, 1, 3, 2]]) >>> b = values.copy() >>> b[ b<3 ] = -1 >>> b[ b==3 ] = 0 >>> b[ b>3 ] = 1 >>> b array([[ 1, 1, -1, -1, -1, 1, -1, -1, -1, 1], [-1, 1, -1, -1, 0, -1, 0, 1, 0, -1], [ 0, 0, 1, 1, -1, -1, 1, -1, -1, -1], [-1, 1, -1, -1, 1, -1, 1, -1, -1, -1], [-1, 1, -1, -1, -1, 0, 0, 1, -1, -1], [-1, 0, 0, 1, -1, -1, -1, -1, 0, -1]])
By the way, this thread claims that creating combinations directly in numpy will give about 5 times the performance than itertools, although, perhaps, due to some readability.