runs

coinflip.randtests.runs.runs(series, candidate)[source]

Actual number of runs is compared to expected result

The number of runs (uninterrupted sequence of the same value) is found, and referenced to a hypothetically truly random RNG.

Parameters:
  • sequence (array-like) – Output of the RNG being tested
  • candidate (Value present in given sequence) – The value which is counted in each block
Returns:

TestResult – Dataclass that contains the test’s statistic and p-value

coinflip.randtests.runs.longest_runs(series, candidate)[source]

Longest runs per block is compared to expected result

The longest number of runs (uninterrupted sequence of the same value) per block is found, and referenced to a hypothetically truly random RNG.

Parameters:
  • sequence (array-like) – Output of the RNG being tested
  • candidate (Value present in given sequence) – The value which is counted in each block
Returns:

TestResult – Dataclass that contains the test’s statistic and p-value

coinflip.randtests.runs.asruns(series) → Iterator[Tuple[Any, int]][source]

Iterator of runs in a Series

Parameters:

series (Series) – Series to represent as runs

Yields:
  • value (Any) – Value of the run
  • length (int) – Length of the run

Notes

A “run” is an uninterrupted sequence of the same value.