cana.function_properties.bias module

Bias

Node bias (fraction of minterms with output 1) of a Boolean function.

Two equivalent routes:

  • bias_from_bit_lut() — dense LUT popcount / 2**k.

  • bias_from_schemata() — ON-fraction over (full or sampled) prime-implicant coverage. Prefer this when PIs are already available, and when k is too large to materialize a dense LUT (MAX_DENSE_LUT_K).

High-k sampling reuses the shared exact/sampled two-track (exact_k_max / n_samples) from sampling. Percentile bootstrap CIs are available via bootstrap_bias().

cana.function_properties.bias.bias_from_bit_lut(bit_lut)[source]

Bias from a dense LUT: popcount / 2**k.

Parameters:

bit_lut (BitLut)

Return type:

float

cana.function_properties.bias.bias_from_schemata(schemata, k=None, *, exact_k_max=14, n_samples=None, rng=None, minterms=None, return_coverage=False, return_mode=False)[source]

Bias with exact / sampled two-track over prime-implicant coverage.

Same exact/sampled two-track and warning / return_mode behaviour as input_redundancy().

Parameters:
  • schemata (Mapping[int, Set[str]])

  • k (int | None)

  • exact_k_max (int)

  • n_samples (int | None)

  • rng (Generator | None)

  • minterms (Sequence[str] | None)

  • return_coverage (bool)

  • return_mode (bool)

Return type:

float | Tuple[float, SampledPiCoverage] | Tuple[float, str] | Tuple[float, SampledPiCoverage, str]

cana.function_properties.bias.bootstrap_bias(sampled_or_schemata=None, *, schemata=None, n_samples=None, n_boot=1000, ci=0.95, rng=None, minterms=None)[source]

Estimate bias with a percentile bootstrap CI on the sample mean.

Prefer passing a preserved SampledPiCoverage so primes are not re-matched. Schemata + n_samples / minterms still work (including the legacy positional schemata call).

Parameters:
  • sampled_or_schemata (SampledPiCoverage | Mapping[int, Set[str]] | None)

  • schemata (Mapping[int, Set[str]] | None)

  • n_samples (int | None)

  • n_boot (int)

  • ci (float)

  • rng (Generator | None)

  • minterms (Sequence[str] | None)

Return type:

BootstrapResult