'Tests that the \'param_cov\' fit_info entry gets the right answer for
*linear* least squares, where the answer is exact'

def test_param_cov(self):

    a = 2
    b = 100
    with NumpyRNGContext(_RANDOM_SEED):
        x = np.linspace(0, 1, 100)
        y = (((x * a) + b) + np.random.randn(len(x)))
    X = np.matrix(np.vstack([x, np.ones(len(x))]).T)
    beta = ((np.linalg.inv((X.T * X)) * X.T) * np.matrix(y).T)
    s2 = (np.sum(((y - (X * beta).A.ravel()) ** 2)) / (len(y) - len(beta)))
    olscov = (np.linalg.inv((X.T * X)) * s2)
    mod = models.Linear1D(a, b)
    fitter = LevMarLSQFitter()
    fmod = fitter(mod, x, y)
    assert_allclose(fmod.parameters, beta.A.ravel())
    assert_allclose(olscov, fitter.fit_info[u'param_cov'])
