class_docstr: class for runs in a binary sequence
  
  
  Parameters
  ----------
  x : array_like, 1d
      data array,
  
  
  Notes
  -----
  This was written as a more general class for runs. This has some redundant
  calculations when only the runs_test is used.
  
  TODO: make it lazy
  
  The runs test could be generalized to more than 1d if there is a use case
  for it.
  
  This should be extended once I figure out what the distribution of runs
  of any length k is.
  
  The exact distribution for the runs test is also available but not yet
  verified.
docstr: basic version of runs test
  
  Parameters
  ----------
  correction : bool
      Following the SAS manual, for samplesize below 50, the test
      statistic is corrected by 0.5. This can be turned off with
      correction=False, and was included to match R, tseries, which
      does not use any correction.
  
  pvalue based on normal distribution, with integer correction
docstr_tok: ["basic","version","of","runs","test","Parameters","--","--","--","--","--","correction",":","bool","Following","the","SAS","manual",",","for","samplesize","below","50",",","the","test","statistic","is","corrected","by","0.5",".","This","can","be","turned","off","with","correction=False",",","and","was","included","to","match","R",",","tseries",",","which","does","not","use","any","correction",".","pvalue","based","on","normal","distribution",",","with","integer","correction"]
code: def runs_test(self, correction=True):
      """basic version of runs test
  
      Parameters
      ----------
      correction : bool
          Following the SAS manual, for samplesize below 50, the test
          statistic is corrected by 0.5. This can be turned off with
          correction=False, and was included to match R, tseries, which
          does not use any correction.
  
      pvalue based on normal distribution, with integer correction
  
      """
      self.npo = npo = (self.runs_pos).sum()
      self.nne = nne = (self.runs_neg).sum()
  
      # n_r = self.n_runs
      n = npo + nne
      npn = npo * nne
      rmean = 2.0 * npn / n + 1
      rvar = 2.0 * npn * (2.0 * npn - n) / n**2.0 / (n - 1.0)
      rstd = np.sqrt(rvar)
      rdemean = self.n_runs - rmean
      if n >= 50 or not correction:
          z = rdemean
      else:
          if rdemean > 0.5:
              z = rdemean - 0.5
          elif rdemean < 0.5:
              z = rdemean + 0.5
          else:
              z = 0.0
  
      z /= rstd
      pval = 2 * stats.norm.sf(np.abs(z))
      return z, pval
  
imports: import numpy
  from scipy import stats
  from scipy.special import comb
  import warnings
  from statsmodels.tools.validation import array_like
label_desc: Use image node_id 2 for calling the Runs obj's underlying member method code with example usage: obj.runs_test(correction) and returns: z,  pval