title: How work the p-value simulation in the chisq.test() and fisher.test()
body: <p>I have contingency tables RxC. How  <code>chisq.test</code> and <code>fisher.test</code> functions work when called with arguments <code>simulate.p.value = TRUE, B = 5000</code> ?</p>
  
  <p>I'm using the code below to validate the association (or independence) in the contingency table <code>DATA</code>:</p>
  
  <pre><code> chisq.test(DATA, simulate.p.value = TRUE, B = 5000, correct = FALSE)
   fisher.test(DATA,hybrid = TRUE, simulate.p.value = TRUE)
  </code></pre>
  
  <p>I know that the test can perform Monte Carlo simulations to estimate the p-value of the test, what I want to know is how these simulations are done internally, that is, if the simulations are made to arrive at a normal distribution or another distribution to deliver the p-value at the end of the test?</p>