EUROPEAN JOURNAL OF PURE AND APPLIED MATHEMATICS Vol. 17, No. 4, 2024, 4225-4237 ISSN 1307-5543 – ejpam.com Published by New York Business Global Weights of Codewords in Random Binary Linear Codes and Their Correlation Properties İbrahim Özen Department of Matheamatics, Faculty of Science, Marmara University, Istanbul, Turkey. Abstract. A classical problem in coding theory addresses moments of the weight spectrum dis- tribution. The results in this work are on the weight moments of individual codewords rather than the weight spectrum. The expectations of single and pairwise products of weights of nonzero words in a random binary linear code are given. We show that the covariance between the weights of any pair of distinct nonzero words is zero. Our main theorem has an application to sequence correlations problem. We prove that the sums of out of phase self correlations, as well as sums of cross-correlations, of nonzero words in a random binary linear code are equal to zero. 2020 Mathematics Subject Classifications: 94B05, 94A55, 94B65 Key Words and Phrases: Random binary linear codes, Weight moments of codewords, Binary sequences, Auto-correlations, Cross-correlations 1. Introduction A binary linear code C is a subspace of Fn 2 . We call n the length of the code. Dimension of the code is its dimension as a linear space. A vector in the code is called a codeword. Let c = (c1, c2, . . . , cn) and e = (e1, e2, . . . , en) be two binary vectors. The Hamming distance between them is the number of coordinates that they differ and is defined by dH(c, e) = |{i : ci ̸= ei}|. For every vector c, the number of nonzero positions in c is called its weight and we denote it by ∥c∥. The smallest weight of the nonzero codewords is called the minimum weight of the code. Since C is a linear space, the minimum weight of the code coincides with the minimum of the distances between distinct codewords of the code. If C ⊂ Fn 2 is a linear code with dimension k and minimum weight d, we say that C is a binary [n, k, d] code. If we let Ai denote the number of codewords with weight i, then the sequence (A0, Ad, Ad+1, . . . , An) is called the weight distribution or the weight spectrum of the code. DOI: https://doi.org/10.29020/nybg.ejpam.v17i4.5600 Email address: iozen@marmara.edu.tr (İ. Özen) https://www.ejpam.com 4225 Copyright: © 2024 The Author(s). (CC BY-NC 4.0) İbrahim Özen / Eur. J. Pure Appl. Math, 17 (4) (2024), 4225-4237 4226 Every important feature of a code is encoded in its weight distribution. For exam- ple, if the weight distribution of a linear code is known we can obtain estimations of its decoding error probability. Gallager estimated the decoding error probability of a ran- dom linear code in [4]. So we have a way to compare this property of a specific code as well as information on what is possible for the same quality. This estimation is based on the expectations of the weight distribution of random linear codes. The expectations of weights are part of the code weight distribution problem, namely the evaluations of the expectations E (Ai1Ai2 · · ·Aik) for random linear codes. Second and third joint moments of the weight distribution of a random linear code were explored in [6] and [1] independently. Fourth moments were given in [8]. In [9] and [7], big orders of the moments were studied. In this work we focus on the weight moments of individual codewords in a random binary linear code. Our results have applications on the expectations of correlation sums of words. Let us denote the words of an [n, k] random binary linear code by C = {c0 = 0, c1, . . . , c2k−1}. The weights of the words will be denoted by {w0 = 0, w1, . . . , w2k−1} respectively. In Theorem 1 we obtain the expectations of the nonzero words’ weights in a random [n, k] binary linear code and they are given by E(wi) = n 2 , for i ̸= 0. Expectations of pairwise products of the weights are obtained in Theorem 2 and they can be stated as E(wiwj) = { n2+n 4 , for i = j, i, j ≥ 1, n2 4 , for i ̸= j, i, j ≥ 1. An immediate consequence is that the weights of distinct nonzero words in a random binary linear code are statistically uncorrelated. covariance(wi, wj) = E(wiwj)− E(wi)E(wj) = 0, for all i, j ≥ 1 and i ̸= j We apply these results to obtain correlation properties of words in a random code. Let c = (c1, c2, . . . , cn) and e = (e1, e2, . . . , en) be two vectors in Fn 2 . The periodic auto-correlation and cross-correlation functions on vectors of Fn 2 are defined respectively by rc,c(u) = rc(u) = n∑ i=1 (−1)ci+ci+u and rc,e(u) = n∑ i=1 (−1)ci+ei+u , İbrahim Özen / Eur. J. Pure Appl. Math, 17 (4) (2024), 4225-4237 4227 where the indices are evaluated modulo n. Let c and e be two distinct nonzero codewords in a random binary linear [n, k] code. We obtain in Theorem 3 that n−1∑ u=1 E(rc(u)) = 0 and n−1∑ u=0 E(rc,e(u)) = 0. 2. Characteristic Vectors of Codes and Weights of Nonzero Codewords Our main theorem is based on the characterization of weights of nonzero words in terms of the characteristic vector of a code, given in [2]. We will review this characterization in the following paragraphs. Let k ≥ 2 and i be integers with 1 ≤ i ≤ 2k−1. We denote by i = (i0, i1, . . . , ik−1) ∈ Fk 2, the binary expansion of i = ∑k−1 j=0 ij2 j . We form the k × (2k − 1) matrix Gk, whose ith column is iT . Let C be a binary linear [n, k] code and let G be a generator matrix of C. We will show below that with high probability a random matrix G has no columns of zeros. We will assume from now on that C is a code with a generator matrix without zero columns. For such C and G, we define the characteristic vector χC of C with respect to G as the vector χC = (h1, h2, . . . , h2k−1) T , where hi is the number of columns in G equal to the ith column iT of Gk. Clearly we have ∑ j hj = n (recall that G has no zero columns). Now since any nonzero codeword is obtained by a nontrivial linear combination of rows of G, all nonzero codewords of C are obtained as the rows of the matrix product GT kG. So we identify the nonzero words of C with the rows of the product GT kG; C = {0}∪{ci}2 k−1 i=1 , where ci is the ith row of GT kG. If we denote the matrix product GT kGk by Mk, we can express the relation between the weights of the nonzero codewords of C and the characteristic vector χC as in the following lemma. Lemma 1. [2, Lemma 1] Let C be a binary [n, k] linear code, let G be a generator matrix of C and let χC be the characteristic vector of C with respect to G. Then the weight of ith row ci of G T kG equals to the ith entry of the column vector MkχC MkχC =  w1 w2 ... w2k−1  , where {w1, w2, . . . , w2k−1} is the set of weights of all nonzero words in C. İbrahim Özen / Eur. J. Pure Appl. Math, 17 (4) (2024), 4225-4237 4228 Let f be a sequence of real numbers of length 2k, whose terms are indexed from 0 to 2k−1 and let us denote by f(i) its ith coordinate. Then we define its Walsh transformation f̂ as a sequence of real numbers with the same length, whose ith entry is given by f̂(i) = 2k−1∑ j=0 f(j)(−1)⟨j,i⟩, 0 ≤ i ≤ 2k − 1, where ⟨ , ⟩ is the standard inner product on Fk 2, i and j are the binary expansions of i and j respectively. From χC = (h1, h2, . . . , h2k−1) T we obtain a sequence of integers of length 2k by χC = (h0 = 0, h1, h2, . . . , h2k−1) T . Then the Walsh transform of χC is the vector whose ith entry is given by χ̂C(i) = 2k−1∑ j=0 χC(j)(−1)⟨j,i⟩ = 2k−1∑ j=0 hj(−1)⟨j,i⟩. We will also need the matrix Mk =  0 0 . . . 0 ... Mk 0  . The Walsh transform of the characteristic vector is expressed in terms of the Hadamard matrix obtained by Sylvester construction. These matrices are constructed recursively with the help of the Hadamard product as follows: H1 = [ 1 1 1 −1 ] , Hi = H1 ⊗Hi−1. If we index the rows and columns of Hk by 0 ≤ i ≤ 2k − 1 and 0 ≤ j ≤ 2k − 1 respectively, then the (i, j) entry of Hk is given by [5, Page 11] Hk[i, j] = (−1)⟨i,j⟩. (1) The lemma below is taken from [2], we will prove it for completeness. Lemma 2. [2, Page 267] Let C be a binary [n, k] linear code, let G be a generator matrix of C, and let χC be the characteristic vector of C with respect to G. Then we have HkχC = (J − 2Mk)χC =  n n− 2w1 n− 2w2 ... n− 2w2k−1  = χ̂C , where J is the all one matrix, {w1, w2, . . . , w2k−1} is the set of weights of all nonzero words in C. İbrahim Özen / Eur. J. Pure Appl. Math, 17 (4) (2024), 4225-4237 4229 Proof. We will index all entries of the matrices and vectors starting from 0. All assertions for the terms indexed by zero are trivial. Let i be an integer with 1 ≤ i ≤ 2k−1. Then by (1) the term indexed by i in the product HkχC equals 2k−1∑ j=0 (−1)⟨i,j⟩χC(j) = 2k−1∑ j=0 (−1)⟨i,j⟩hj , (2) with i and j being the binary representations of i and j respectively. The same term in the product (J − 2Mk)χC is ∑2k−1 j=0 (1− 2⟨si, sj⟩)hj , where sl’s are the column vectors of Gk. One can easily confirm that we have 1− 2⟨si, sj⟩ = 1− 2⟨i, j⟩ = (−1)⟨i,j⟩. So we have ∑2k−1 j=0 (1− 2⟨si, sj⟩)hj = ∑2k−1 j=0 (−1)⟨i,j⟩hj and by (2), the first equality of the lemma follows. The second equality follows from Lemma 1. If we compare the ith coordinates of HkχC and χ̂C we obtain the last equality of the lemma (HkχC)(i) = 2k−1∑ j=0 hj(−1)⟨i,j⟩ = χ̂C(i). In the next section we will make use of the identity in the following lemma. The assertion of the first line is trivial and the second line is an easy consequence of [3, Lemma 3, Page 58]. Lemma 3. For any integer 0 ≤ i ≤ 2k − 1, we have 2k−1∑ j=0 (−1)⟨j,i⟩ = { 2k, for i = 0, 0, for i ̸= 0. 3. First and Second Moments of the Codeword Weights A random binary linear code is the row-space of a random k×n matrix, whose entries are identically and independently distributed in F2. A well known property of a random k×n matrix over a finite field is that when k/n < 1, the matrix has rank k with probability tending to 1, as n tends to infinity. So we will assume that a random binary k × n matrix whose terms are distributed identically and independently in F2 has rank k and its row space C is an [n, k] linear code. The words of such a code will be denoted by C = {c0 = 0, c1, c2, . . . , c2k−1}, with the same relation to GT kG as above. The weights of the nonzero words will be denoted by {w1, w2, . . . , w2k−1} respectively. Another fact about this ensemble of matrices is that, the probability that a random k × n matrix has zero columns tends to 0 as n tends to infinity with k/n > 0. This can easily be observed by lim n→∞ 1− (2k − 1)n 2kn = 0, İbrahim Özen / Eur. J. Pure Appl. Math, 17 (4) (2024), 4225-4237 4230 with the condition that R = k/n ̸= 0. By Lemma 2, the expectations of weights of the nonzero codewords in a random code can be calculated by E(n− 2wi) = E (χ̂C(i)) = 2k−1∑ j=0 E(hj)(−1)⟨j,i⟩. For a positive integer n, we denote by [n] the set {0, 1, . . . , n − 1}. We can calculate the expectations of the pairwise products of nonzero words’ weights as follows. E[(n− 2wi)(n− 2wj)] = E (χ̂C(i)χ̂C(j)) = ∑ s,m∈[2k] E(hshm)(−1)⟨s,i⟩+⟨m,j⟩. Let us denote by P (hs), the probability that a random binary k×n matrix has exactly hs columns that are equal to sT , for 0 ≤ s ≤ 2k − 1. Similarly, let P (hs, hm) denote the probability that a random matrix has exactly hs columns equal to sT and hm columns equal to mT , for 0 ≤ s,m ≤ 2k − 1 and s ̸= m. Proposition 1. For a random binary k × n matrix, we have P (hs) = ( n hs ) (2k − 1)(n−hs) 2kn and P (hs, hm) = ( n hs + hm )( hs + hm hm ) (2k − 2)(n−(hs+hm)) 2kn · Proof. The number of matrices with exactly hs columns equal to sT is given by( n hs ) (2k − 1)(n−hs). The binomial coefficient gives the number of different choices for placing sT and the factor (2k − 1)(n−hs) counts the number of ways to fill the other columns with the remaining (2k − 1) vectors arbitrarily. The number of k × n binary matrices is 2kn. So we have P (hs) = ( n hs ) (2k − 1)(n−hs) 2kn · Now let 0 ≤ s,m ≤ 2k − 1 and s ̸= m. For the number of k × n binary matrices with exactly hs columns equal to sT and hm columns equal to mT , we fix (hs + hm) positions for sT and mT . Hence we have the binomial coefficient ( n hs+hm ) . Then we determine the hm positions among the (hs + hm) columns for the vector mT . The number of choices İbrahim Özen / Eur. J. Pure Appl. Math, 17 (4) (2024), 4225-4237 4231 for that is ( hs+hm hm ) . The choice for columns sT is determined by that of mT uniquely. The columns other than these (hs + hm) positions can be filled by the remaining (2k − 2) vectors arbitrarily. So we have P (hs, hm) = ( n hs + hm )( hs + hm hm ) (2k − 2)(n−(hs+hm)) 2kn · Theorem 1. Let C be a random binary linear [n, k] code with words and weights denoted as above. Then the expectations of the weights of nonzero codewords are given by E(wi) = n 2 for i ≥ 1. (3) Proof. By Lemma 2, we have E(n− 2wi) = E (χ̂C(i)) = ∑ s∈[2k] E(hs)(−1)⟨s,i⟩. By Proposition 1 we proceed as follows: E(n− 2wi) = ∑ s∈[2k] E(hs)(−1)⟨s,i⟩ = ∑ s∈[2k] ∑ hs∈[n+1] P (hs)hs(−1)⟨s,i⟩ = ∑ s∈[2k] ∑ hs∈[n+1] ( n hs ) (2k − 1)n−hs 2kn hs(−1)⟨s,i⟩ = ∑ s∈[2k] ∑ hs∈[n+1] ( n hs ) (2k − 1)hs 2kn (n− hs)(−1)⟨s,i⟩ In the last equality we performed a change of variables and put (n−hs) for hs, by the symmetry of the binomial coefficients. Let K1 = 2k−1. In the following equation we have derivative with respect to K1. E(n− 2wi) = ∑ s∈[2k] ( n− K1 2kn [(K1 + 1)n]′ ) (−1)⟨s,i⟩ = ( n− K1 2kn [ n(2k)n−1 ]) ∑ s∈[2k] (−1)⟨s,i⟩ = ( n 2k ) ∑ s∈[2k] (−1)⟨s,i⟩ = 0 for i ≥ 1. İbrahim Özen / Eur. J. Pure Appl. Math, 17 (4) (2024), 4225-4237 4232 The last equality is obtained by Lemma 3. So the expectations of the nonzero weights follow E(wi) = n 2 for i ≥ 1. We will explore the expectations of the products of nonzero weights in the next theo- rem. Theorem 2. Expectations of the pairwise products of nonzero weights in a random binary linear [n, k] code are given by E(wiwj) = { n2+n 4 , for i = j, i, j ≥ 1, n2 4 , for i ̸= j, i, j ≥ 1. (4) Proof. By Lemma 2, the expectations of the products of nonzero weights are given by E((n− 2wi)(n− 2wj)) = E (χ̂C(i)χ̂C(j)) = ∑ s,m∈[2k] E(hshm)(−1)⟨s,i⟩+⟨m,j⟩ = ∑ s∈[2k] E(h2s)(−1)⟨s,(i+j)⟩ + ∑ s,m∈[2k] s ̸=m E(hshm)(−1)⟨s,i⟩+⟨m,j⟩. The first sum in the last equality is the contribution of cases where s = m and the second sum is the contribution of the cases where s ̸= m. Now let K1 and K2 denote 2k − 1 and 2k − 2 respectively. E((n− 2wi)(n− 2wj))= 1 2kn ∑ s∈[2k] hs∈[n+1] ( n hs ) K (n−hs) 1 h2s(−1)⟨s,(i+j)⟩ + ∑ s,m∈[2k] s ̸=m hs,hm∈[n+1] ( n hm hs ) K (n−hs−hm) 2 hshm(−1)⟨s,i⟩+⟨m,j⟩ 2kn , where ( n hm hs ) = n! (hm)!(hs)!(n− (hm + hs))! is the multinomial coefficient. We continue with a change of variables T = hs + hm in the second sum and we get E((n− 2wi)(n− 2wj))= 1 2kn ∑ s∈[2k] hs∈[n+1] ( n hs ) K (n−hs) 1 h2s(−1)⟨s,(i+j)⟩ İbrahim Özen / Eur. J. Pure Appl. Math, 17 (4) (2024), 4225-4237 4233 + ∑ s,m∈[2k] s ̸=m T∈[n+1] hm∈[T+1] ( n T )( T hm ) K (n−T ) 2 (T − hm)hm(−1)⟨s,i⟩+⟨m,j⟩ 2kn = 1 2kn ∑ s∈[2k] hs∈[n+1] ( n hs ) K (n−hs) 1 (h2s − hs)(−1)⟨s,(i+j)⟩ + 1 2kn ∑ s∈[2k] hs∈[n+1] ( n hs ) K (n−hs) 1 hs(−1)⟨s,(i+j)⟩ − ∑ s,m∈[2k] s ̸=m T∈[n+1] hm∈[T+1] ( n T )( T hm ) K (n−T ) 2 (h2m − hm)(−1)⟨s,i⟩+⟨m,j⟩ 2kn + ∑ s,m∈[2k] s ̸=m T∈[n+1] hm∈[T+1] ( n T )( T hm ) K (n−T ) 2 (T − 1)hm(−1)⟨s,i⟩+⟨m,j⟩ 2kn (5) After summation over hs, hm and T we obtain the following, where the derivatives are taken with respect to the variables u and v. After derivatives we substitute u = 1 and v = 2. E((n− 2wi)(n− 2wj)) = 1 2kn ∑ s∈[2k] [(K1 + u)n]′′(−1)⟨s,(i+j)⟩ + 1 2kn ∑ s∈[2k] [(K1 + u)n]′(−1)⟨s,(i+j)⟩ + 1 2kn ∑ s,m∈[2k] s̸=m [(K2 + v)n]′′(−1)⟨s,i⟩+⟨m,j)⟩ = n(n− 1) 22k ∑ s∈[2k] (−1)⟨s,(i+j)⟩ İbrahim Özen / Eur. J. Pure Appl. Math, 17 (4) (2024), 4225-4237 4234 + n 2k ∑ s∈[2k] (−1)⟨s,(i+j)⟩ + n(n− 1) 22k ∑ s,m∈[2k] s ̸=m (−1)⟨s,i⟩+⟨m,j)⟩ By Lemma 3 the result is E((n− 2wi)(n− 2wj)) = { n, for i = j, i, j ≥ 1, 0, for i ̸= j, i, j ≥ 1. Finally we get the expectations of products of nonzero codeword weights as E(wiwj) = { n2+n 4 , for i = j, i, j ≥ 1, n2 4 , for i ̸= j, i, j ≥ 1. Two random variables X and Y are called statistically uncorrelated if the covariance between them is 0, cov(X,Y ) = E(XY )− E(X)E(Y ) = 0. We observe that this is the case for the weights of distinct nonzero codewords in a random code. Corollary 1. Weights of distinct nonzero words of a random binary linear code are un- correlated cov(wi, wj) = 0, for all i, j ≥ 1 and i ̸= j. 4. Correlation Properties of Nonzero Words in a Random Binary Liner Code Let c = (c1, c2, . . . , cn) and e = (e1, e2, . . . , en) be two vectors in Fn 2 . We define the periodic auto-correlation and cross-correlation functions on vectors of Fn 2 as follows rc,c(u) = rc(u) = n∑ i=1 (−1)ci+ci+u and rc,e(u) = n∑ i=1 (−1)ci+ei+u respectively. The indices are evaluated modulo n. Given e ∈ Fn 2 let us denote by eu, the vector obtained by shifting each coordinate of e by u to the left eu = (e1+u, e2+u, . . . , en, e1, . . . , eu). İbrahim Özen / Eur. J. Pure Appl. Math, 17 (4) (2024), 4225-4237 4235 The correlation functions rc and rc,e evaluates the following: If in a coordinate the vectors agree, then this coordinates contributes a (+1) and if the the entries in the same co- ordinate are different this coordinate contributes a (−1). So we can rewrite the correlation functions as follows rc(u) = n∑ i=1 (−1)ci+ci+u = n− 2dH(c, cu) and (6) rc,e(u) = n∑ i=1 (−1)ci+ei+u = n− 2dH(c, eu), (7) where dH is the Hamming distance. The following formulation of Hamming distance on Fn 2 will be useful dH(c, e) = ∥c∥+ ∥e∥ − 2⟨c, e⟩, (8) where ∥ · ∥ denotes the weight of the vector and the inner product is evaluated over R. The following theorem gives the expectations of sums of auto-correlations and sums of cross-correlations between the nonzero words in a random binary linear code. Theorem 3. Let C be a random binary linear [n, k] code and let c and e be two distinct nonzero codewords. Then we have n−1∑ u=1 E(rc(u)) = 0 and n−1∑ u=0 E(rc,e(u)) = 0. Proof. By (6) and (8) we have rc(u) = n− 2dH(c, cu) = n− 2(∥c∥+ ∥cu∥ − 2⟨c, cu⟩). Summation over u and taking expectations of both sides gives n−1∑ u=1 E(rc(u)) = n−1∑ u=1 [n− 2(E(∥c∥) + E(∥cu∥)− 2E(⟨c, cu⟩))] = −n(n− 1) + 4E ( n−1∑ u=1 ⟨c, cu⟩ ) . In the last equation we made use of (3). Now we will utilize the following simple fact: For any c = (c1, c2, . . . , cn) and e = (e1, e2, . . . , en) in Fn 2 we have ∥c∥∥e∥ = (c1 + c2 + . . .+ cn)(e1 + e2 + . . .+ en) REFERENCES 4236 = n−1∑ u=0 ⟨c, eu⟩. (9) With this fact, (3) and (4), we have n−1∑ u=1 E(rc(u)) = −n(n− 1) + 4 (E(∥c∥∥c∥)− E(∥c∥)) = −n(n− 1) + 4 ( n2 + n 4 − n 2 ) = 0. (10) Now let c and e be two distinct nonzero codewords in C. For the cross-correlations, following the same steps as above we get n−1∑ u=0 E(rc,e(u))) = n−1∑ u=0 E[n− 2dH(c, eu)] = n−1∑ u=0 [n− 2(E(∥c∥) + E(∥eu∥)− 2E(⟨c, eu⟩))] = −n2 + 4E ( n−1∑ u=0 ⟨c, eu⟩ ) = −n2 + 4E(∥c∥∥e∥). Finally by (4) we get the result n−1∑ u=0 E(rc,e(u)) = 0. 5. Conclusion We obtained the expectations of single and pairwise products of weights of codewords in random binary linear codes. We showed that the weights of two nonzero words are statistically uncorrelated. We used the expectations of the products of nonzero weights to show that the expectations of the sums of out of phase auto-correlations and the expec- tations of the sums of cross-correlations of nonzero words are zero. References [1] V Blinovsky, U Erez, and S Litsyn. Weight distribution moments of random lin- ear/coset codes. Design. Code. Cryptogr., 57:127–138, 2010. REFERENCES 4237 [2] I Bouyukliev, S Bouyuklieva, T Maruta, and P Piperkov. Characteristic vector and weight distribution of a linear code. Cryptogr. Commun., 13:263–282, 2021. [3] C Carlet. Boolean Functions for Cryptography and Coding Theory. Cambridge Uni- versity Press, Cambridge, 2021. [4] R G Gallager. Low Density Parity Check Codes. MIT Press, Cambridge, 1963. [5] K J Horadam. Hadamard Matrices and Their Applications. Princeton University Press, 2012. [6] A A Klyachko and I. Özen. Correlations between the ranks of submatrices and weights of random codes. Finite Fields T. App., 15(4):497–516, 2009. [7] N Linial and J Mosheiff. On the weight distribution of random binary linear codes. Random Struct. Alg., 56:5–36, 2020. [8] I Özen. Fourth moments of the code-weights. Commun. Algebra, 51(4):1761–1771, 2023. [9] A Samorodnitsky. Weight distribution of random linear codes and krawtchouk poly- nomials. Random Struct. Alg., 65:261–274, 2024.