template

coinflip.randtests.template.non_overlapping_template_matching(series, template: List[T] = None, nblocks=None)[source]

Matches of template per block is compared to expected result

The sequence is split into blocks, where the number of non-overlapping matches to the template in each block is found. This is referenced to the expected mean and variance in matches of a hypothetically truly random RNG.

Parameters:
  • sequence (array-like) – Output of the RNG being tested
  • template (List, optional) – Template to match with the sequence, randomly generated if not provided.
  • nblocks (int) – Number of blocks to split sequence into
Returns:

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

Raises:

TemplateContainsElementsNotInSequenceError – If template contains values not present in sequence

coinflip.randtests.template.overlapping_template_matching(series, template: List[T] = None, nblocks=None, df=5)[source]

Overlapping matches of template per block is compared to expected result

The sequence is split into nblocks blocks, where the number of overlapping matches to the template in each block is found. This is referenced to the expected mean and variance in matches of a hypothetically truly random RNG.

Deprecated since version 0: df will be removed once I figure out the correct value, as I don’t quite understand what NIST wants (or if they’re even correct!)

Parameters:
  • sequence (array-like) – Output of the RNG being tested
  • template (List, optional) – Template to match with the sequence, randomly generated if not provided.
  • nblocks (int) – Number of blocks to split sequence into
  • df (int, default 5) – Degrees of freedom to use in p-value calculation
Returns:

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

Raises:

TemplateContainsElementsNotInSequenceError – If template contains values not present in sequence