HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/statsmodels/sandbox/distributions/tests/test_gof_new.py
import numpy as np
from numpy.testing import assert_array_almost_equal

from statsmodels.sandbox.distributions.gof_new import bootstrap, NewNorm


def test_loop_vectorized_batch_equivalence():
    # test equality of loop, vectorized, batch-vectorized
    nobs = 200

    np.random.seed(8765679)
    resu1 = bootstrap(NewNorm(), args=(0, 1), nobs=nobs, nrep=100,
                      value=0.576/(1 + 4./nobs - 25./nobs**2))

    np.random.seed(8765679)
    tmp = [bootstrap(NewNorm(), args=(0, 1), nobs=nobs, nrep=1)
           for _ in range(100)]
    resu2 = (np.array(tmp) > 0.576/(1 + 4./nobs - 25./nobs**2)).mean()

    np.random.seed(8765679)
    tmp = [bootstrap(NewNorm(), args=(0, 1), nobs=nobs, nrep=1,
                     value=0.576/(1 + 4./nobs - 25./nobs**2),
                     batch_size=10) for _ in range(10)]
    resu3 = np.array(tmp).mean()

    assert_array_almost_equal(resu1, resu2, 15)
    assert_array_almost_equal(resu2, resu3, 15)