Your code did not use `pkk` though you calculated. ` pkk = [dot(eye(len(k[index])) - dot(k[index], self.h), comp.cov) `