Module params

Module params 

Source
Expand description

Network-aware coding parameters — adaptive k computation.

§Problem

Given a network of N Pouch peers, each with an independent availability probability p_i (the stability score from crate::network::qos), and given a target high recovery probability Ph, we need to find the largest integer k such that:

P(X ≥ k) ≥ Ph     where  X = Σ Bernoulli(p_i)

X follows a Poisson-Binomial distribution.

§Normal approximation

For the sizes encountered in practice (N ≥ 5), the Poisson-Binomial can be approximated by a normal distribution with matching mean and variance:

μ  = Σ p_i              (expected recoverable fragments)
σ² = Σ p_i·(1−p_i)      (variance)

P(X ≥ k) ≈ 1 − Φ((k − 0.5 − μ) / σ)   ← continuity correction

Solving for k:

k = ⌊ μ − z(Ph) · σ + 0.5 ⌋

where z(Ph) is the standard-normal Ph-quantile (probit).

§Redundancy overhead q

The total number of fragments distributed per chunk is:

n = round(k · (1 + q_target))
q = (n − k) / k              (effective overhead fraction)

The default q_target = 1.0 means each chunk generates ~2k fragments (one copy-equivalent of redundancy on top of the recovery threshold).

§Rolling pe

After upload, the actual observed probability pe can be recomputed at any time using effective_recovery_probability with the latest stability scores and the stored k.

Structs§

NetworkCodingParams
Coding parameters computed for a specific network state and target Ph.

Functions§

compute_coding_params
Compute the optimal coding parameters for the given network state.
compute_network_storage_factor
Compute the network storage utilisation factor k / N.
effective_recovery_probability
Recompute the rolling effective recovery probability Pe for a file that was uploaded with threshold k, given the current stability scores.
probit
Inverse standard normal CDF (probit) using the Beasley-Springer-Moro rational approximation. Accurate to ~10⁻⁹ for p ∈ (10⁻⁶, 1−10⁻⁶).
standard_normal_cdf
Standard normal CDF Φ(x) using a rational approximation.