code: def test_runstest(reset_randomstate):
      # comparison numbers from R, tseries, runs.test
      # currently only 2-sided used
      x = np.array([1, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1])
  
      z_twosided = 1.386750
      pvalue_twosided = 0.1655179
  
      z_greater = 1.386750
      pvalue_greater = 0.08275893
  
      z_less = 1.386750
      pvalue_less = 0.917241
  
      # print Runs(x).runs_test(correction=False)
      assert_almost_equal(
          np.array(Runs(x).runs_test(correction=False)),
          [z_twosided, pvalue_twosided],
          decimal=6,
      )
  
      # compare with runstest_1samp which should have same indicator
      assert_almost_equal(
          runstest_1samp(x, correction=False),
          [z_twosided, pvalue_twosided],
          decimal=6,
      )
  
      x2 = x - 0.5 + np.random.uniform(-0.1, 0.1, size=len(x))
      assert_almost_equal(
          runstest_1samp(x2, cutoff=0, correction=False),
          [z_twosided, pvalue_twosided],
          decimal=6,
      )
  
      assert_almost_equal(
          runstest_1samp(x2, cutoff="mean", correction=False),
          [z_twosided, pvalue_twosided],
          decimal=6,
      )
      assert_almost_equal(
          runstest_1samp(x2, cutoff=x2.mean(), correction=False),
          [z_twosided, pvalue_twosided],
          decimal=6,
      )
  
      # check median
      assert_almost_equal(
          runstest_1samp(x2, cutoff="median", correction=False),
          runstest_1samp(x2, cutoff=np.median(x2), correction=False),
          decimal=6,
      )
  
imports: from statsmodels.compat.python import lzip
  import numpy
  from numpy.testing import assert_allclose, assert_almost_equal, assert_approx_equal, assert_
  from scipy import stats
  import pytest
  from statsmodels.stats.contingency_tables import mcnemar, cochrans_q, SquareTable
  from statsmodels.sandbox.stats.runs import Runs, runstest_1samp, runstest_2samp
  from statsmodels.sandbox.stats.runs import mcnemar
  from statsmodels.stats.nonparametric import rank_compare_2indep, rank_compare_2ordinal, prob_larger_continuous, cohensd2problarger
  from statsmodels.tools.testing import Holder
label_desc: Use image node_id 9 for calling a global function with example usage: test_runstest(reset_randomstate) without return types