expect_mc_iid_chisq: Test iid samples for correct cdf using chisq test

Description Usage Arguments Value Examples

View source: R/expect_mc.R

Description

Test if samples are behaving like an iid sample from a given distribution via the chisq test and a sequential approach. Only works for discrete distributions taking finitely many values.

Usage

1
expect_mc_iid_chisq(object, prob, control = NULL)

Arguments

object

A function taking one argument - that generates n univariate iid samples.

prob

A vector of probabilities for finitely many consecutive integers from 0 onward.

control

a list controlling the algorithm

  • n number of samples to be taken in the first step. Default: 1e3

  • maxseqsteps: Number of sequential attempts to use. Default: 7.

  • incn: Factor by which to multiply n from the second sequential attempt onward. Default: 4.

  • level: bound on the type I error, ie the probability of wrongly rejecting a sampler with the correct distribution. Default: 1e-5.

  • debug: If positive then debug information will be printed via 'message()'. Default: 0.

Value

The first argument, invisibly, to allow chaining of expectations.

Examples

1
2
3
   sampler <- function(n) rbinom(n,prob=0.6,size=5)
   expect_mc_iid_chisq(sampler, dbinom(0:5,prob=0.6,size=5))
   testthat::expect_error(expect_mc_iid_chisq(sampler, dbinom(0:5,prob=0.63,size=5)))

mcunit documentation built on April 2, 2021, 5:06 p.m.