Binary Cross-Correlation Calculator
Calculate cross-correlation between two binary sequences at a selected lag. Compare overlapping bits using bipolar binary mapping and view raw correlation, normalized correlation, matches and mismatches.
Raw Rxy(k) = Σ A[n] × B[n+k]
Normalized Rxy(k) = Raw Sum ÷ Overlap Length
-
-
-
What Is Binary Cross-Correlation?
Binary cross-correlation measures the similarity between two binary sequences while allowing one sequence to be compared at a selected relative shift, called lag. It is useful when the relationship between two digital bit streams depends not only on their values but also on their alignment.
For this calculator, binary values are converted into bipolar values before multiplication. Binary 1 becomes +1 and binary 0 becomes -1. This mapping produces a convenient correlation scale where agreements contribute +1 and disagreements contribute -1.
Binary Cross-Correlation Formula
After bipolar conversion, the raw cross-correlation for the overlapping region is the sum of the pairwise products.
The normalized value is:
This normalization keeps the result between -1 and +1 regardless of the overlap length.
Why Map Binary 0 to -1 and 1 to +1?
If ordinary binary values 0 and 1 were multiplied directly, every pair containing a zero would contribute zero. That would make it difficult to distinguish agreement on zero bits from disagreement.
Bipolar mapping solves this problem.
| Bit A | Bit B | Bipolar Values | Product |
|---|---|---|---|
| 1 | 1 | +1 × +1 | +1 |
| 0 | 0 | -1 × -1 | +1 |
| 1 | 0 | +1 × -1 | -1 |
| 0 | 1 | -1 × +1 | -1 |
Normalized Binary Cross-Correlation
The normalized result ranges from -1 to +1.
| Correlation | Meaning for Overlapping Bits |
|---|---|
| +1 | Every compared bit matches |
| 0 | Matches and mismatches contribute equally |
| -1 | Every compared bit is opposite |
Values between these endpoints represent intermediate levels of agreement.
Cross-Correlation at Lag 0
Lag 0 compares both sequences without shifting either one.
B: 11010011
Every position agrees, so all eight bipolar products are +1.
Overlap: 8
Normalized: 8 / 8 = 1
Negative Binary Cross-Correlation
Consider two sequences where every bit is opposite:
B: 00110101
Every overlapping pair produces a bipolar product of -1.
Normalized: -8 / 8 = -1
Zero Cross-Correlation Example
If the number of agreements equals the number of disagreements, the positive and negative products cancel.
Raw: 4 – 4 = 0
Normalized: 0
What Is Lag in Cross-Correlation?
Lag specifies the relative displacement between the two binary sequences before the correlation is calculated.
At lag 0, corresponding positions are compared directly. At a positive or negative lag, only positions that still overlap are included.
Lag: 2
Overlap: 6 bits
The non-overlapping endpoints are excluded rather than padded with artificial values.
Positive Lag Example
Suppose both sequences contain eight bits and lag is +2. The calculator compares the first six usable positions of Sequence A with Sequence B beginning two positions later.
B index: 2 3 4 5 6 7
The resulting correlation is calculated from those six overlapping pairs only.
Negative Lag Example
A negative lag shifts the comparison in the opposite direction.
A index: 2 3 4 5 6 7
B index: 0 1 2 3 4 5
Again, only the overlapping six positions contribute to the result.
Overlap Length
For two equal-length sequences of length N, the overlap decreases as the absolute lag increases.
For a 16-bit sequence:
Lag 3: 13 overlapping bits
Lag -5: 11 overlapping bits
Raw vs Normalized Cross-Correlation
Raw correlation depends directly on the number of overlapping pairs. Normalized correlation divides the raw sum by overlap length so results at different valid lags can be expressed on the same -1 to +1 scale.
| Measurement | Range | Depends on Overlap Length? |
|---|---|---|
| Raw Correlation | -L through +L | Yes |
| Normalized Correlation | -1 through +1 | Normalized |
Here, L is the number of overlapping bit pairs.
Binary Matches and Correlation
With bipolar mapping, each matching binary pair contributes +1 and each mismatch contributes -1.
That means the raw cross-correlation can also be understood as:
For example:
Mismatches: 3
Raw: 7 – 3 = 4
Overlap: 10
Normalized: 0.4
Cross-Correlation vs Hamming Distance
Hamming distance counts mismatching positions between equal-length aligned sequences. Cross-correlation provides a signed similarity measurement and can also evaluate the sequences at a non-zero lag.
| Tool | Main Measurement |
|---|---|
| Hamming Distance | Number of differing aligned bits |
| Cross-Correlation | Signed similarity at a selected relative lag |
Binary Cross-Correlation vs Autocorrelation
Cross-correlation compares two different sequences. Autocorrelation compares a sequence with a shifted version of itself.
Autocorrelation: Sequence A vs shifted Sequence A
For that reason, BinaryCon keeps the Binary Autocorrelation Calculator as a separate tool rather than merging both calculations.
Cross-Correlation and Digital Communications
Binary correlation concepts are used in digital communications to compare known patterns with observed bit or symbol sequences. Correlation can help quantify how closely two aligned or shifted patterns agree.
Applications can include synchronization research, sequence detection, spread-spectrum concepts, digital signal analysis and communication-system education.
Cross-Correlation in Pseudorandom Binary Sequences
Cross-correlation can also be studied when comparing pseudorandom binary sequences. Sequences designed for communication or coding applications may be evaluated partly by how strongly they correlate under different alignments.
This calculator reports correlation for the selected lag only. It does not automatically scan every lag or judge whether a sequence has desirable pseudorandom properties.
Cross-Correlation Is Not Statistical Pearson Correlation
The calculation on this page is sequence cross-correlation using bipolar binary symbols and a selected lag. It should not be confused with a conventional Pearson correlation coefficient calculated from paired continuous observations.
Although the normalized result also lies between -1 and +1, the underlying calculation and intended use are different.
Why Equal Sequence Lengths Are Required
This calculator requires the original two sequences to have the same length so lag behavior is clear and predictable. The overlap is then determined entirely by the selected lag.
Allowed lag: -(N-1) through +(N-1)
At the largest valid positive or negative lag, exactly one pair of bits remains overlapping.
Important Binary Cross-Correlation Notes
Binary 0 is mapped to -1.
Binary 1 is mapped to +1.
The two original sequences must have equal length.
Lag may range from -(N-1) through +(N-1), where N is sequence length.
Only overlapping positions are included.
Raw correlation equals the sum of bipolar products.
Normalized correlation equals raw correlation divided by overlap length.
Normalized correlation ranges from -1 through +1.
A matching binary pair contributes +1, while a mismatching pair contributes -1.
This calculator does not automatically search all lags, calculate autocorrelation, perform FFT analysis or determine whether the sequences are random.