Gray coding, also known as a reflected binary code, is a bit-to-symbol mapping strategy where adjacent points in a signal constellation diagram differ by exactly one bit. This geometric property ensures that when noise causes a received IQ sample to cross a decision boundary into a neighboring Voronoi region, the resulting symbol error produces only a single bit error rather than a multi-bit burst.
Glossary
Gray Coding

What is Gray Coding?
A bit-to-symbol mapping scheme where adjacent constellation points differ by only a single bit, ensuring that the most likely symbol errors caused by noise crossing a decision boundary result in the minimum possible number of bit errors.
This technique is a standard feature in high-order Quadrature Amplitude Modulation (QAM) and Phase Shift Keying (PSK) schemes, directly improving the effective Bit Error Rate (BER) by approximately a factor of log2(M) compared to uncoded mapping. In likelihood-based modulation classifiers and blind receivers, knowledge of the Gray coding structure is often leveraged during symbol mapping reconstruction to resolve phase ambiguity after constellation recovery.
Key Characteristics of Gray Coding
Gray coding is a bit-to-symbol mapping scheme where adjacent constellation points differ by only a single bit, ensuring that the most likely symbol errors caused by noise crossing a decision boundary result in the minimum possible number of bit errors.
The Single-Bit Adjacency Rule
The defining property of Gray coding is that any two constellation points sharing a Voronoi region boundary differ in exactly one bit position. This is not a natural binary sequence but a re-mapped ordering. For example, in standard binary, the transition from 3 (011) to 4 (100) flips three bits, but in Gray code, the sequence is 3 (010) to 4 (110), flipping only the most significant bit. This geometric constraint ensures that when additive white Gaussian noise (AWGN) pushes a received symbol across a decision boundary into an adjacent region, only a single bit error occurs.
Bit Error Rate (BER) Optimization
In high signal-to-noise ratio (SNR) regimes, symbol errors are dominated by nearest-neighbor misclassifications. Gray coding directly minimizes the Bit Error Rate (BER) by ensuring each dominant symbol error event causes only one bit flip. The theoretical approximation for Gray-coded M-ary modulation is:
- BER ≈ Symbol Error Rate / log2(M) This relationship holds because each symbol carries log2(M) bits, and a single symbol error corrupts exactly one bit. Without Gray coding, a single symbol error could corrupt multiple bits, degrading BER performance by up to a factor of log2(M).
Hamming Distance of One
The Hamming distance between the bit labels of any two adjacent constellation points is exactly 1. This is the fundamental algebraic property that distinguishes Gray coding from arbitrary symbol mappings. Key implications:
- The mapping is an isometry between the geometric adjacency graph of the constellation and the hypercube graph of the binary labels.
- For Quadrature Amplitude Modulation (QAM) constellations, perfect Gray coding exists only when the constellation forms a rectangular grid where each dimension's pulse amplitude modulation (PAM) levels can be independently Gray-coded.
- For non-rectangular constellations like Amplitude Phase Shift Keying (APSK) or cross-QAM, true Gray coding may not exist, requiring approximate or quasi-Gray mappings.
Construction via Reflected Binary Code
Gray code for one-dimensional PAM, which extends to two-dimensional QAM, is generated using the reflected binary code algorithm:
- Start with a 1-bit code: [0, 1]
- To generate n+1 bits, reflect the n-bit code (reverse the list) and prefix the original half with 0 and the reflected half with 1.
- Example: 2-bit code = [00, 01, 11, 10]; 3-bit code = [000, 001, 011, 010, 110, 111, 101, 100]. For M-QAM, the in-phase and quadrature components are independently mapped using this PAM Gray code, producing a two-dimensional labeling where both horizontal and vertical neighbors differ by one bit.
Impact on Soft-Decision Decoding
Gray coding significantly improves the performance of soft-decision forward error correction (FEC) decoders, such as low-density parity-check (LDPC) and turbo codes. The mechanism:
- Soft demappers compute log-likelihood ratios (LLRs) for each bit based on the received symbol's position relative to all constellation points.
- Under Gray mapping, the LLR for a given bit depends primarily on the nearest decision boundary for that bit position, simplifying computation and reducing correlation between bit LLRs.
- This near-independence of bit LLRs aligns with the assumption of most binary FEC decoders, preventing the iterative decoding process from being misled by correlated bit error patterns that occur with non-Gray mappings.
Limitations and Quasi-Gray Mappings
Perfect Gray coding is not universally achievable:
- Cross-QAM constellations (e.g., 32-QAM, 128-QAM) have non-rectangular shapes where corner points have fewer than four neighbors, breaking the perfect grid adjacency required for true Gray coding.
- APSK constellations with multiple concentric rings create adjacency patterns where a point may have more neighbors than available single-bit-difference labels.
- In these cases, quasi-Gray mapping algorithms minimize the average Hamming distance between adjacent points using search heuristics or integer programming. The result is a mapping where most, but not all, adjacent pairs differ by one bit, with the remaining pairs differing by two bits.
Gray Coding vs. Natural Binary Coding
Comparison of bit-to-symbol mapping schemes for minimizing bit errors in digital modulation constellations.
| Feature | Gray Coding | Natural Binary Coding | Anti-Gray Coding |
|---|---|---|---|
Adjacent symbol bit difference | 1 bit | Variable (1 to k bits) | Maximum (k bits) |
Most likely symbol error result | Single bit error | Multiple bit errors | All bits in error |
BER approximation for high SNR | SER / k | ≈ SER × (k+1) / 2k | ≈ SER |
Hamming distance between neighbors | 1 | 1 to k | k |
Mapping complexity | Reflective binary algorithm | Sequential binary count | Inverse Gray algorithm |
Typical use case | QAM, PSK, APSK | Legacy systems, unipolar | Theoretical worst-case |
Error floor improvement over natural binary | Baseline (optimal) | 3-4 dB worse at 10⁻⁶ BER |
|
Decoding dependency | None (independent bits) | Adjacent bit dependency | Full symbol dependency |
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Frequently Asked Questions
Explore the fundamental principles of Gray coding, a bit-to-symbol mapping scheme that minimizes bit errors in noisy communication channels by ensuring adjacent constellation points differ by only a single bit.
Gray coding is a bit-to-symbol mapping scheme where adjacent constellation points in the IQ plane differ by exactly one bit. Named after Frank Gray, who patented the code in 1953, its core mechanism ensures that when noise causes a symbol error—pushing a received point across a decision boundary into a neighboring Voronoi region—the resulting bit error is minimized to a single flipped bit rather than multiple simultaneous errors. For example, in a standard 16-QAM constellation with natural binary mapping, moving from symbol 0111 to 1000 would flip all four bits. With Gray coding, the same spatial transition might only flip one bit, dramatically reducing the bit error rate (BER) for the same signal-to-noise ratio. This property makes Gray coding the de facto standard in virtually all modern digital communication systems, including LTE, 5G NR, WiFi, and satellite links.
Related Terms
Understanding Gray coding requires familiarity with the geometric and statistical properties of digital modulation. These core concepts define how bits map to symbols and how noise impacts error performance.
Symbol Mapping
The deterministic process of assigning a unique complex-valued constellation point to a specific group of input bits. The mapping scheme directly dictates the bit error rate (BER) performance. Gray coding is the optimal mapping strategy for minimizing bit errors, as it ensures that adjacent symbols—those most likely to be confused by noise—differ by only a single bit.
Decision Boundary
A geometric threshold in the IQ plane that partitions the signal space into Voronoi regions. Each region defines the set of received points that will be assigned to a specific constellation symbol during demodulation. Gray coding's benefit is realized precisely when noise pushes a symbol across a decision boundary into an adjacent region, causing only a single bit flip instead of multiple errors.
Euclidean Distance
The straight-line geometric distance between two points in the complex signal plane. In minimum distance decoding, a received noisy symbol is classified as the constellation point with the smallest Euclidean distance to the observation. Gray coding is effective because the most probable symbol errors—those crossing to the nearest neighbor—correspond to the smallest Euclidean distances.
Quadrature Amplitude Modulation (QAM)
A high spectral efficiency modulation scheme that conveys data by modulating both the amplitude and phase of a carrier. QAM produces a rectangular or cross-shaped constellation. Gray coding is standard for QAM constellations (e.g., 16-QAM, 64-QAM) to ensure that the most likely symbol errors caused by crossing a vertical or horizontal decision boundary result in only a single bit error.
Phase Shift Keying (PSK)
A modulation format that encodes data solely by changing the phase of a carrier wave while maintaining constant amplitude. Constellation points lie on a circle. For M-PSK, Gray coding assigns bit patterns such that adjacent phase states differ by one bit. This is critical because thermal noise typically rotates the received phase into an adjacent angular sector.
Bit Error Rate (BER)
The primary performance metric quantifying the fraction of transmitted bits that are incorrectly decoded. Gray coding directly optimizes BER by decoupling symbol errors from bit errors. Under a high signal-to-noise ratio (SNR), a single symbol error caused by crossing a decision boundary results in approximately 1 bit error rather than log₂(M) potential errors, providing a significant coding gain.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us