multinomial_test#

scio.scores.utils.multinomial_test(counts, prior, mode)[source]#

Prepare test after having observed counts, with prior belief.

Parameters:
  • counts (Tensor) – Observed counts. Shape (*batch_shape, k)

  • prior (Tensor) – Prior pseudo-count. Set to ones for no a priori. Shape (k,).

  • mode (MultinomialTestModeLike) – See MultinomialTestMode.

Returns:

test (Callable[[Tensor], Tensor]) – Deviation test function test(observed: Tensor) -> Tensor, where observed can be batched. Depending on mode, this function defines the test “expectations” by aggregating the observed counts and the prior.

Raises:
  • ValueError – If counts is a scalar.

  • ValueError – If mode value is unsupported.

Note

In principle, if counts indeed represents counting results, then counts.sum(-1) should hold the same value for every sample. This is not checked at runtime. The same applies to observed.