Channel Coding Demo

📡 Linear Block Codes

A linear block code takes a message of k bits and encodes it into a codeword of n bits. The extra n − k bits are redundancy — carefully chosen so the receiver can detect (and sometimes correct) transmission errors.

(n, k, d)q — length n, message k, min-distance d, alphabet size q

Code length (n)

Total bits in the transmitted codeword

Message length (k)

Original information bits before encoding

Redundancy (n − k)

Extra bits added for error protection

Rate R = k/n

Fraction of useful info per transmitted bit

Two Classic Codes

The Binary Repetition Code repeats every message bit n times. To send 1, transmit 1 1 1 … 1.

Rate = 1/n  |  Very robust, very inefficient

The Single-Parity Check (SPC) Code appends one extra bit so that the total number of 1s in the codeword is even.

Rate = (n−1)/n  |  Efficient, detects 1-bit errors

⚙️ Generator Matrix

Encoding is simply a matrix multiplication over binary arithmetic (GF(2)):

c = u · G

u is the 1×k message row vector, G is the k×n generator matrix, and c is the 1×n codeword. All arithmetic uses modulo 2 (addition is XOR, multiplication is AND).

Animated Matrix Multiplication

Watch step-by-step how each bit of c is computed as a dot product of u with a column of G.

Press Start Animation to begin.

Why Systematic Form?

When the first k×k block of G is an identity matrix, G is called systematic. The first k bits of the codeword c are then identical to the message u — easy to decode!

Gsystematic = [ Ik | P ]

Example: SPC (4,3) systematic generator matrix

🔍 Parity Check Matrix

The parity-check matrix H has size (n−k)×n and satisfies a key property: for every valid codeword c,

c · Hᵀ = 0

If a received word r has been corrupted, then r · Hᵀ = s ≠ 0. This non-zero vector s is called the syndrome.

s = 0 (zero syndrome)

Word belongs to the valid codeword set → no detected error

s ≠ 0 (non-zero syndrome)

Word was corrupted — an error was introduced in the channel

Animated Syndrome Check

See how H multiplied by a valid or corrupted codeword gives zero or a non-zero syndrome.

Enter a received word and press Compute Syndrome.

🛠️ Interactive Encoder

Build your own code by defining how each parity bit is computed from the message bits. The app will construct the generator matrix G automatically.

Step 1 — Choose message length k

Step 2 — Define each parity bit

Each parity bit pᵢ = XOR of the selected message bits (even-parity rule)

Step 3 — Resulting Generator Matrix G

Step 4 — Encode a message

🔄 G ↔ H Conversion

For binary codes (q=2), once G is in systematic form [Ik | P], the parity-check matrix H is simply:

H = [ Pᵀ | In−k ]

This works because multiplying H by any valid codeword cᵀ = [u, uP]ᵀ gives Pᵀuᵀ + uPᵀ = 0 over GF(2).

🌪️ Noise Playground

Simulate a noisy channel. Encode a message, flip bits, and watch the syndrome reveal the error.

Click bits to flip them (simulate noise)

🧩 Standard array

The standard array groups all length-n binary vectors into cosets of the code. The first row contains all valid codewords, and each next row is built by adding a coset leader.