class_docstr: class to run Monte Carlo study on a statistical test'''
  
  TODO
  print(summary, for quantiles and for histogram
  draft in trying out script log
  
  Parameters
  ----------
  dgp : callable
      Function that generates the data to be used in Monte Carlo that should
      return a new sample with each call
  statistic : callable
      Function that calculates the test statistic, which can return either
      a single statistic or a 1d array_like (tuple, list, ndarray).
      see also statindices in description of run
  
  Attributes
  ----------
  many methods store intermediate results
  
  self.mcres : ndarray (nrepl, nreturns) or (nrepl, len(statindices))
      Monte Carlo results stored by run
  
  
  Notes
  -----
  
  .. Warning::
     This is (currently) designed for a single call to run. If run is
     called a second time with different arguments, then some attributes might
     not be updated, and, therefore, not correspond to the same run.
  
  .. Warning::
     Under Construction, do not expect stability in Api or implementation
  
  
  Examples
  --------
  
  Define a function that defines our test statistic:
  
  def lb(x):
      s,p = acorr_ljungbox(x, lags=4)
      return np.r_[s, p]
  
  Note lb returns eight values.
  
  Define a random sample generator, for example 500 independently, normal
  distributed observations in a sample:
  
  
  def normalnoisesim(nobs=500, loc=0.0):
      return (loc+np.random.randn(nobs))
  
  Create instance and run Monte Carlo. Using statindices=list(range(4)) means that
  only the first for values of the return of the statistic (lb) are stored
  in the Monte Carlo results.
  
  mc1 = StatTestMC(normalnoisesim, lb)
  mc1.run(5000, statindices=list(range(4)))
  
  Most of the other methods take an idx which indicates for which columns
  the results should be presented, e.g.
  
  print(mc1.cdf(crit, [1,2,3])[1]
class_docstr_tok: ["class","to","run","Monte","Carlo","study","on","a","statistical","test","''","'","TODO","print","(","summary",",","for","quantiles","and","for","histogram","draft","in","trying","out","script","log","Parameters","--","--","--","--","--","dgp",":","callable","Function","that","generates","the","data","to","be","used","in","Monte","Carlo","that","should","return","a","new","sample","with","each","call","statistic",":","callable","Function","that","calculates","the","test","statistic",",","which","can","return","either","a","single","statistic","or","a","1d","array_like","(","tuple",",","list",",","ndarray",")",".","see","also","statindices","in","description","of","run","Attributes","--","--","--","--","--","many","methods","store","intermediate","results","self.mcres",":","ndarray","(","nrepl",",","nreturns",")","or","(","nrepl",",","len","(","statindices",")",")","Monte","Carlo","results","stored","by","run","Notes","--","--","-","..","Warning",":",":","This","is","(","currently",")","designed","for","a","single","call","to","run",".","If","run","is","called","a","second","time","with","different","arguments",",","then","some","attributes","might","not","be","updated",",","and",",","therefore",",","not","correspond","to","the","same","run",".","..","Warning",":",":","Under","Construction",",","do","not","expect","stability","in","Api","or","implementation","Examples","--","--","--","--","Define","a","function","that","defines","our","test","statistic",":","def","lb","(","x",")",":","s",",","p","=","acorr_ljungbox","(","x",",","lags=4",")","return","np.r_","[","s",",","p","]","Note","lb","returns","eight","values",".","Define","a","random","sample","generator",",","for","example","500","independently",",","normal","distributed","observations","in","a","sample",":","def","normalnoisesim","(","nobs=500",",","loc=0.0",")",":","return","(","loc+np.random.randn","(","nobs",")",")","Create","instance","and","run","Monte","Carlo",".","Using","statindices=list","(","range","(","4",")",")","means","that","only","the","first","for","values","of","the","return","of","the","statistic","(","lb",")","are","stored","in","the","Monte","Carlo","results",".","mc1","=","StatTestMC","(","normalnoisesim",",","lb",")","mc1.run","(","5000",",","statindices=list","(","range","(","4",")",")",")","Most","of","the","other","methods","take","an","idx","which","indicates","for","which","columns","the","results","should","be","presented",",","e.g",".","print","(","mc1.cdf","(","crit",",","[","1,2,3","]",")","[","1","]"]
code: def __init__(self, dgp, statistic):
      self.dgp = dgp  # staticmethod(dgp)  #no self
      self.statistic = statistic
  
file_path: statsmodels/statsmodels/sandbox/tools/mctools.py
imports: from statsmodels.compat.python import lrange
  import numpy
  from statsmodels.iolib.table import SimpleTable
label_desc: Use image node_id 1 to create a new StatTestMC object  with example: obj = StatTestMC(dgp, statistic)