def sim(A):

            while True:
                y = np.random.standard_normal(L.shape[1])
                if con(y):
                    break
            return chisq.quadratic_test(y, np.identity(con.dim), con)
def test_chisq_central(nsim=None, burnin=8000, ndraw=2000):

    n, p = 4, 10
    A, b = np.random.standard_normal((n, p)), np.zeros(n)
    con = AC.constraints(A,b)

    while True:
        z = np.random.standard_normal(p)
        if con(z):
            break

    S = np.identity(p)[:3]
    Z = AC.sample_from_constraints(con, z, ndraw=ndraw, burnin=burnin)
    P = []
    for i in range(Z.shape[0]/10):
        P.append(chisq.quadratic_test(Z[10*i], S, con))

#     no plots in the test!
#     ecdf = sm.distributions.ECDF(P)

#     plt.clf()
#     x = np.linspace(0,1,101)
#     plt.plot(x, ecdf(x), c='red')
#     plt.plot([0,1],[0,1], c='blue', linewidth=2)

    nt.assert_true(np.fabs(np.mean(P)-0.5) < 0.03)
    nt.assert_true(np.fabs(np.std(P)-1/np.sqrt(12)) < 0.03)
def test_chisq_central(nsim=None, burnin=8000, ndraw=2000):

    n, p = 4, 10
    A, b = np.random.standard_normal((n, p)), np.zeros(n)
    con = AC.constraints(A, b)

    while True:
        z = np.random.standard_normal(p)
        if con(z):
            break

    S = np.identity(p)[:3]
    Z = AC.sample_from_constraints(con, z, ndraw=ndraw, burnin=burnin)
    P = []
    for i in range(Z.shape[0] / 10):
        P.append(chisq.quadratic_test(Z[10 * i], S, con))


#     no plots in the test!
#     ecdf = sm.distributions.ECDF(P)

#     plt.clf()
#     x = np.linspace(0,1,101)
#     plt.plot(x, ecdf(x), c='red')
#     plt.plot([0,1],[0,1], c='blue', linewidth=2)

    nt.assert_true(np.fabs(np.mean(P) - 0.5) < 0.03)
    nt.assert_true(np.fabs(np.std(P) - 1 / np.sqrt(12)) < 0.03)
        def sim(A):

            while True:
                y = np.random.standard_normal(L.shape[1])
                if con(y):
                    break
            return chisq.quadratic_test(y, np.identity(con.dim),
                                        con)
def test_chisq_central(nsim=None, burnin=8000, ndraw=2000):

    n, p = 4, 10
    A, b = np.random.standard_normal((n, p)), np.zeros(n)
    con = AC.constraints(A, b)

    while True:
        z = np.random.standard_normal(p)
        if con(z):
            break

    S = np.identity(p)[:3]
    Z = AC.sample_from_constraints(con, z, ndraw=ndraw, burnin=burnin)
    P = []
    for i in range(int(Z.shape[0] / 10)):
        P.append(chisq.quadratic_test(Z[10 * i], S, con))

    nt.assert_true(np.fabs(np.mean(P) - 0.5) < 0.03)
    nt.assert_true(np.fabs(np.std(P) - 1 / np.sqrt(12)) < 0.03)