Skip to main content
`Ctrl`+`K`
scipy.stats.

# MonteCarloMethod

class scipy.stats.MonteCarloMethod(n_resamples=9999, batch=None, rvs=None, rng=None)

  Configuration information for a Monte Carlo hypothesis test.

  Instances of this class can be passed into the method parameter of some hypothesis test functions to perform a Monte Carlo version of the hypothesis tests.

  Attributes:
    n_resamplesint, optional

      The number of Monte Carlo samples to draw. Default is 9999.

    batchint, optional

      The number of Monte Carlo samples to process in each vectorized call to the statistic. Batch sizes >>1 tend to be faster when the statistic is vectorized, but memory usage scales linearly with the batch size. Default is `None`, which processes all samples in a single batch.

    rvscallable or tuple of callables, optional

      A callable or sequence of callables that generates random variates under the null hypothesis. Each element of `rvs` must be a callable that accepts keyword argument `size` (e.g. `rvs(size=(m, n))`) and returns an N-d array sample of that shape. If `rvs` is a sequence, the number of callables in `rvs` must match the number of samples passed to the hypothesis test in which the `MonteCarloMethod` is used. Default is `None`, in which case the hypothesis test function chooses values to match the standard version of the hypothesis test. For example, the null hypothesis of `scipy.stats.pearsonr` is typically that the samples are drawn from the standard normal distribution, so `rvs = (rng.normal, rng.normal)` where `rng = np.random.default_rng()`.

    rng `numpy.random.Generator`, optional

      Pseudorandom number generator state. When `rng` is None, a new `numpy.random.Generator` is created using entropy from the operating system. Types other than `numpy.random.Generator` are passed to `numpy.random.default_rng` to instantiate a `Generator`.