arXiv:2611.07156cs.ITNov 2026

Manuscript Offprint

arXiv:2611.07156

Lossless Source Coding with Marginal Distribution Constraint

Cheuk Ting Li, Jun Chen, Shahab Asoodeh

Abstract

We consider lossless source coding with a marginal distribution constraint on the encoding symbols (SC-MDC). Unlike distribution matching, signal shaping and homophonic coding which require the symbols to be (approximately) i.i.d. following a target distribution, SC-MDC requires each symbol to have a marginal distribution that exactly matches the target distribution, which can be regarded as a perfect perceptual quality constraint on the symbols, and may have applications to wear leveling, source coding with cost and steganography. We give nonasymptotic lower and upper bounds on the optimal encoding length, and exactly characterize the coding rate (or the first-order term of the length) when the source distribution or the target distribution is uniform, or when the source is an i.i.d. sequence.

I. INTRODUCTION

Consider a lossless source coding setting with a marginal distribution constraint (SC-MDC) on the encoding symbols. We encode a source X∼PX \sim P, supported on X\mathcal{X}, into a sequence of encoding symbols Y1,…,YmY_1, \ldots, Y_m from Y\mathcal{Y} via a stochastic encoder PY1,…,Ym∣XP_{Y_1,\ldots,Y_m|X}, so that the source can be recovered exactly, i.e., H(X∣Y1,…,Ym)=0H(X|Y_1,\ldots,Y_m) = 0. Unlike conventional source coding where we only impose a constraint on the alphabet Y\mathcal{Y} (e.g., Y={0,1}\mathcal{Y} = \{0,1\}), we impose a constraint on the marginal distribution that Yi∼QY_i \sim Q for i∈[m]i \in [m], where QQ is a given target distribution. The goal is to find the smallest possible length mm.

This problem is equivalent to finding a coupling between PP and mm copies of QQ (i.e., X∼P,Yi∼QX \sim P, Y_i \sim Q for i∈[m]i \in [m]) satisfying H(X∣Y1,…,Ym)=0H(X|Y_1,\ldots,Y_m) = 0. The smallest mm is given by the following quantity which we call coupled aggregation number:

m∗(P∥Q):=min⁡{m∈Z≥0:∃Qˉ∈Γm(Q),Qˉ⊆P},m^*(P\|Q) := \min \{m \in \mathbb{Z}_{\geq 0} : \exists \bar{Q} \in \Gamma_m(Q), \bar{Q} \subseteq P\},

where Γm(Q)\Gamma_m(Q) is the set of all couplings of mm copies of QQ, i.e., the set of possible joint distributions of Y1,…,YmY_1, \ldots, Y_m where Yi∼QY_i \sim Q, 1^1 and Qˉ⊆P\bar{Q} \subseteq P (PP is an aggregation of Qˉ\bar{Q} [1], [2], [3]) if there exists a function ff such that if Yˉ∼Qˉ\bar{Y} \sim \bar{Q}, then f(Yˉ)∼P2f(\bar{Y}) \sim P^2.

This quantity was introduced in the setting of learning with totally unpaired data [4], which concerns the smallest possible value of H(X∣Y1,…,Ym)H(X|Y_1,\ldots,Y_m) given the marginal distributions of X,Y1,…,YmX, Y_1,\ldots,Y_m, which corresponds to the smallest average cross entropy loss of predicting XX given the features Y1,…,YmY_1,\ldots,Y_m when only their marginals are known, i.e., when we only have m+1m+1 unpaired datasets, one for each of X,Y1,…,YmX, Y_1,\ldots,Y_m. The value of m∗(P∥Q)m^*(P\|Q) is the smallest number of identically distributed features Y1,…,YmY_1,\ldots,Y_m that allow perfect prediction of XX, i.e., H(X∣Y1,…,Ym)=0H(X|Y_1,\ldots,Y_m) = 0.

This setting is also related to distribution matching [5], [6], [7], signal shaping [8], [9] and homophonic coding [10], [11], [12], which require Y1,…,YmY_1,\ldots,Y_m to be approximately i.i.d. following QQ (this is only satisfied weakly in the sense of vanishing normalized divergence for distribution matching [13], [7], or requires fixed-to-variable or variable-to-fixed codes for homophonic coding [10], [11], [12]; see Section II for details). We instead impose a marginal distribution constraint Yi∼QY_i \sim Q, which must be satisfied exactly. We list some motivations for imposing marginal constraints:

  • Encoding with perfect perceptual quality. Suppose we encode X∼PX \sim P into a sequence of images Y1,…,YmY_1,\ldots,Y_m, and we want each image to have a high perceptual quality. In the literature of rate-distortion-perception trade-off [14], [15], [16], [17], YiY_i having perfect perceptual quality means Yi∼QY_i \sim Q where QQ is a natural distribution of images (this is referred to as weak-sense perfect perceptual quality in [17]). More generally, if QQ is a natural distribution for the type of data YiY_i belongs to (e.g., audio, DNA strand, chemical solution), then Yi∼QY_i \sim Q would make YiY_i indistinguishable from a natural sample. We can also relax the perceptual constraint by only requiring the divergence between QQ and the distribution of YiY_i to be small, and study the rate-perception trade-off; see Section VI.

  • Wear leveling. Consider a visible light communication setting where we use an array of mm LEDs (YiY_i is the intensity of the ii-th LED) to transmit XX (e.g., see [18]). Having the same marginal distribution ensures the same amount of lumen depreciation for each LED in the long run. If we apply on-off keying where Yi∈{0,1}Y_i \in \{0,1\}, we may want to ensure

§C. T. Li is with the Department of Information Engineering, The Chinese University of Hong Kong, Hong Kong, China (email: cti1@ie.cuhk.edu.hk).

†J. Chen is with the Department of Electrical and Computer Engineering, McMaster University, Hamilton, ON L8S 4K1, Canada (email: chen-jun@mcmaster.ca).

‡S. Asoodeh is with Vector Institute and the Department of Computing and Software, McMaster University, Hamilton, ON L8S 4K1, Canada (email: asoodeh@mcmaster.ca).

1Γ0(Q)^1\Gamma_0(Q) has only one element, which is the degenerate distribution at ∅\emptyset (the zero-length sequence).

2^2We take m∗(P∥Q)=∞m^*(P\|Q) = \infty if no such mm exists.

Yi∼Bern(ρ)Y_i \sim \text{Bern}(\rho) for a small ρ\rho, so the LEDs wear evenly. 3^3 This is also applicable to flash memory where we have mm cells, the wear of the ii-th cell can depend on the level YiY_i programmed to the cell [19], and we want the cells to wear evenly.

  • Unknown or adversarial cost per symbol. Different values of YiY_i may require a different amount of energy or cost to store or transmit [20], [21]. Controlling the distribution of YiY_i allows us to limit the expected cost. SC-MDC is particularly useful when the cost function is unknown and may be different for each YiY_i, or equivalently, the cost c(Yi,zi)c(Y_i, z_i) of YiY_i also depends on an unknown or adversarial state zi∈Zz_i \in \mathcal{Z}. For example, in flash memory [19], the cost (energy or wear) of writing to a cell depends not only on the target level YiY_i, but also on its previous level ziz_i. We minimize the worst-case average cost
cˉ:=max⁡zm∈Zm1mE[∑i=1mc(Yi,zi)].\bar{c}:=\max_{z^{m}\in\mathcal{Z}^{m}}\frac{1}{m}\mathbb{E}\bigg[\sum_{i=1}^{m}c(Y_{i},z_{i})\bigg].

Since we are minimizing a worst-case expectation, a stochastic encoder (like a mixed strategy in game theory) is generally needed. If the minimax optimal distribution

argmin⁡Qmax⁡z∈ZEY∼Q[c(Y,z)](1)\operatorname*{argmin}_{Q}\max_{z\in\mathcal{Z}}\mathbb{E}_{Y\sim Q}[c(Y,z)] \tag{1}

is unique, then attaining the optimal worst-case average cost cˉ\bar{c} is equivalent to fulfilling the marginal distribution constraint Yi∼QY_i \sim Q where QQ is the minimizer in (1) (assuming that the constraint can be fulfilled), since cˉ=m−1∑imax⁡z∈ZE[c(Yi,z)]\bar{c} = m^{-1} \sum_i \max_{z \in \mathcal{Z}} \mathbb{E}[c(Y_i, z)] is minimized if and only if Yi∼QY_i \sim Q.^4 For example, if Yi,zi∈{0,1}Y_i, z_i \in \{0,1\} are the new and previous bits stored in a cell, respectively, and c(1,0)=α>0c(1,0) = \alpha > 0 (it costs α\alpha to change 0 to 1), c(0,1)=β>0c(0,1) = \beta > 0, c(0,0)=c(1,1)=0c(0,0) = c(1,1) = 0, then the unique optimal QQ is Bern(β/(α+β))\text{Bern}(\beta/(\alpha + \beta)), and we should ensure Yi∼QY_i \sim Q. Other techniques such as constant composition codes [7] would not give an exact optimality guarantee.

  • Steganography with limited adversary. Consider a steganography system similar to [22], [23], where an encoder wants to send a plaintext TT to a decoder by producing stegotexts Y1,…,YmY_1, \ldots, Y_m. The encoder and decoder share a secret key KK, and the plaintext must be recoverable from the stegotexts and the key, i.e., H(T∣Y1,…,Ym,K)=0H(T|Y_1, \ldots, Y_m, K) = 0. The goal is to ensure that a limited adversary who only observes any one stegotext YiY_i would not be able to know that communication is occurring. Assuming QQ is the coverttext distribution (the distribution if no communication is occurring), we require Yi∼QY_i \sim Q for each ii. One method is to encrypt TT into a uniformly-distributed ciphertext CC (e.g., via one-time pad [24] C=T⊕KC = T \oplus K where C,T,K∈{0,1}ℓC, T, K \in \{0,1\}^\ell, K∼Unif({0,1}ℓ)K \sim \text{Unif}(\{0,1\}^\ell)), and apply SC-MDC to encode CC into Y1,…,YmY_1, \ldots, Y_m.^5 This can also be regarded as a covert communication setting [25], where we ensure that a warden which only observes one YiY_i cannot detect the communication.

The number of encoding symbols needed by SC-MDC is m∗(P∥Q)m^{*}(P\|Q), which can be interpreted as an operational measure of the ratio of the information in P to the information in Q. One would expect

m∗(P∥Q)≈Hα(P)Hβ(Q),(2)m^{*}(P\|Q)\approx\frac{H_{\alpha}(P)}{H_{\beta}(Q)}, \tag{2}

where Hα,HβH_{\alpha}, H_{\beta} are certain entropy measures. The question is whether they should be the Shannon entropy H, the Hartley entropy H0H_{0} [26] or the min-entropy H∞H_{\infty} [27]. We will prove various bounds on m∗(P∥Q)m^{*}(P\|Q) that are indeed in the form of the ratio in (2). The choice of entropy measures would depend on the scenario, i.e., whether we consider arbitrary P, Q, or whether we fix Q and let the entropy of P become larger, or let P be an i.i.d. product distribution with increasing length. To summarize the key results in this paper:

• For general P,QP, Q (Theorem 1, Proposition 1),

max⁡{H(P)H(Q),H0(P)H0(Q)}≤m∗(P∥Q)<H0(P)+1H∞(Q)+3.(3)\max\left\{\frac{H(P)}{H(Q)},\frac{H_{0}(P)}{H_{0}(Q)}\right\}\leq m^{*}(P\|Q)<\frac{H_{0}(P)+1}{H_{\infty}(Q)}+3. \tag{3}

The upper bound is approximately H0(P)/H∞(Q)H_{0}(P)/H_{\infty}(Q), which is the “most conservative” bound in the form Hα(P)/Hβ(Q)H_{\alpha}(P)/H_{\beta}(Q) since H0H_{0} is the largest and H∞H_{\infty} is the smallest among H,H0,H∞H, H_{0}, H_{\infty}. The upper and lower bounds do not match unless QQ is uniform. For the special case Q=Bern(1/2)Q = \mathrm{Bern}(1/2), the bounds approximately match, and we can show that

⌈H0(P)⌉≤m∗(P∥Bern(1/2))≤⌈H0(P)⌉+1.\lceil H_{0}(P)\rceil\leq m^{*}(P\|\mathrm{B e r n}(1/2))\leq\lceil H_{0}(P)\rceil+1.

Hence, the number of bits needed to encode X∼PX \sim P, if we require each bit to be Bern(1/2)\text{Bern}(1/2), is approximately H0(P)H_0(P) within 2 bits. Comparing this to the classical result [26] that the number of bits needed without the marginal constraint is approximately H0(P)H_0(P) within 1 bit, we can see that the marginal constraint only adds a penalty of 1 bit.

3^{3}Using a code with a small number of 1's (e.g., a constant composition code [7]) is not sufficient if the same code is used repeatedly. For example, if the code sets Y1=1Y_{1}=1 for most choices of X, then the first LED will wear quickly, even though the total number of 1's may be small.

4^{4}The case where the minimizer is not unique is addressed in Section VI.

5^{5}Steganography via minimum entropy coupling was studied in [23]. The difference is that we allow multiple stegotexts, where the adversary can only observe one of them. We also require H(T∣Y1,…,Ym,K)=0H(T|Y_1,\ldots,Y_m,K)=0 exactly.

• If H0(P)H_{0}(P) is large, we have a better upper bound (Theorem 3)

m∗(P∥Q)≤H0(P)H(Q)+O((H0(P))2/3),(4)m^{*}(P\|Q)\leq\frac{H_{0}(P)}{H(Q)}+O\big((H_{0}(P))^{2/3}\big), \tag{4}

where the constant in O(⋅)O(\cdot) only depends on QQ. This upper bound ≈H0(P)/H(Q)\approx H_0(P)/H(Q) is better than the ≈H0(P)/H∞(Q)\approx H_0(P)/H_\infty(Q) in (3), at the expense of having an O(⋅)O(\cdot) term that makes the bound usable only when H0(P)≫H(Q)H_0(P) \gg H(Q), which is a reasonable assumption for source coding since the whole source sequence usually has a much larger entropy than one encoding symbol. The upper bound (4) approximately matches the lower bound in (3) when PP is uniform, which yields

m∗(Bern(1/2)⊗n∥Q)=nH(Q)+O(n2/3).m^{*}(\mathrm{B e r n}(1/2)^{\otimes n}\|Q)=\frac{n}{H(Q)}+O(n^{2/3}).

This gives a new operational meaning of entropy, as H(Q)=lim⁡n→∞n/m∗(Bern(1/2)⊗n∥Q)H(Q) = \lim_{n \to \infty} n/m^*(\mathrm{Bern}(1/2)^{\otimes n}\|Q) is the asymptotic number of i.i.d. source bits that can be encoded per symbol Yi∼QY_i \sim Q.

• For a source distribution P⊗nP^{\otimes n} which is an i.i.d. product distribution, we have (Theorem 4)

m∗(P⊗n∥Q)=nmax⁡{H(P)H(Q),H0(P)H0(Q)}+o(n).(5)m^{*}(P^{\otimes n}\|Q)=n\max\left\{\frac{H(P)}{H(Q)},\frac{H_{0}(P)}{H_{0}(Q)}\right\}+o(n). \tag{5}

This shows the asymptotic tightness of the lower bound in (3), and is asymptotically tighter than (4) at the expense of requiring an i.i.d. product distribution. In particular, for P with finite support, we have

m∗(P⊗n∥Geom(1/2))=nH(P)2+o(n).m^{*}(P^{\otimes n}\|\mathrm{G e o m}(1/2))=\frac{n H(P)}{2}+o(n).

This gives another new operational meaning of entropy via the following source coding setting. Suppose we encode Xn∼P⊗nX^n \sim P^{\otimes n} into Y1,…,Y[nR]∈Z≥0Y_1, \ldots, Y_{[nR]} \in \mathbb{Z}_{\geq 0}, where we have a cost constraint E[Yi]≤1\mathbb{E}[Y_i] \leq 1 for every ii. The optimal rate RR as n→∞n \to \infty is H(P)/2H(P)/2. Interestingly, the optimal rate is given in terms of entropy, even though the setting is fixed-length and zero-error.

• Continuing the i.i.d. setting for general QQ, if we allow a vanishing error probability ϵ\epsilon in the source coding setting, or equivalently, allow a vanishing total variation distance from P⊗nP^{\otimes n}, then the optimal coding rate is (Theorem 7)

lim⁡ϵ→0lim sup⁡n→∞1ninf⁡P^:dTV(P⊗n,P^)≤ϵm∗(P^∥Q)=H(P)H(Q).(6)\lim_{\epsilon\to0}\limsup_{n\to\infty}\frac{1}{n}\inf_{\hat{P}:d_{\mathrm{TV}}(P^{\otimes n},\hat{P})\leq\epsilon}m^{*}(\hat{P}\|Q)=\frac{H(P)}{H(Q)}. \tag{6}

• Continuing the i.i.d. setting, if we instead allow YiY_i to only approximately follow QQ by imposing a constraint on the divergence δ(Q,PYi)≤Δ\delta(Q, P_{Y_i}) \leq \Delta (which can be regarded as a perception constraint) where δ\delta is convex in its second argument, then the optimal coding rate is (Theorem 6)

max⁡{H(P)sup⁡Q^:δ(Q,Q^)≤ΔH(Q^),H0(P)sup⁡Q^:δ(Q,Q^)≤ΔH0(Q^)},\max\bigg\{\frac{H(P)}{\sup_{\hat{Q}:\delta(Q,\hat{Q})\leq\Delta}H(\hat{Q})},\frac{H_{0}(P)}{\sup_{\hat{Q}:\delta(Q,\hat{Q})\leq\Delta}H_{0}(\hat{Q})}\bigg\},

which generalizes (5). We call this the SC-MDC rate-perception function.

References (45)