XCORR Binary Sequence Similarity

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.

Cross-Correlation Selected Lag -1 to +1 Bipolar Mapping Sequence Alignment
Binary Cross-Correlation 0 → -1 · 1 → +1
Enter the first reference binary sequence.
Enter the second binary sequence of the same length.
Positive lag shifts Sequence B to the left relative to A for comparison. Negative lag shifts the overlapping comparison in the opposite direction.
Bipolar mapping: 0 → -1, 1 → +1
Raw Rxy(k) = Σ A[n] × B[n+k]
Normalized Rxy(k) = Raw Sum ÷ Overlap Length
The normalized result ranges from -1 to +1. A value of +1 means every overlapping bipolar bit agrees, -1 means every overlapping bipolar bit is opposite, and values near 0 indicate a more balanced mix of agreements and disagreements.
Binary Cross-Correlation Result
Normalized Correlation
Raw Correlation
Selected Lag
Overlap Length
Matching Bits
Mismatching Bits
Agreement Rate
Sequence Length
Correlation Scale
Overlapping Binary Bits
A bits -
B bits -
Compare -

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.

Raw correlation: Rxy(k) = Σ A[n] × B[n+k]

The normalized value is:

Normalized correlation = Raw correlation ÷ Number of overlapping bits

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.

A: 11010011

B: 11010011

Every position agrees, so all eight bipolar products are +1.

Raw correlation: 8

Overlap: 8

Normalized: 8 / 8 = 1

Negative Binary Cross-Correlation

Consider two sequences where every bit is opposite:

A: 11001010

B: 00110101

Every overlapping pair produces a bipolar product of -1.

Raw: -8

Normalized: -8 / 8 = -1

Zero Cross-Correlation Example

If the number of agreements equals the number of disagreements, the positive and negative products cancel.

4 matching positions + 4 mismatching positions

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.

Sequence length: 8

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.

A index: 0 1 2 3 4 5

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.

Lag: -2

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.

Overlap Length = N – |lag|

For a 16-bit sequence:

Lag 0: 16 overlapping bits

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:

Raw Correlation = Matches – Mismatches

For example:

Matches: 7

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.

Cross-correlation: Sequence A vs Sequence B

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.

Sequence length: N

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

Important: this calculator uses bipolar binary mapping.

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.

Binary Cross-Correlation Calculator FAQs

What does the Binary Cross-Correlation Calculator do?
It measures the similarity of two equal-length binary sequences at a selected lag using bipolar 0=-1 and 1=+1 mapping.
What does a correlation of +1 mean?
It means every overlapping binary position matches at the selected lag.
What does a correlation of -1 mean?
It means every overlapping binary position contains opposite bits.
What does correlation near 0 mean?
It means positive and negative bipolar products largely cancel, usually because agreements and disagreements are comparatively balanced.
Why is binary 0 mapped to -1?
Bipolar mapping allows both 0-0 and 1-1 agreements to contribute +1, while opposite bits contribute -1.
What is lag 0?
Lag 0 compares the two sequences directly without any relative shift.
What happens when lag increases?
The number of overlapping positions decreases. Only those overlapping bit pairs contribute to the correlation.
What is raw binary cross-correlation?
It is the sum of the bipolar products across all overlapping positions.
What is normalized binary cross-correlation?
It is the raw correlation divided by the number of overlapping positions, producing a value from -1 to +1.
Is cross-correlation the same as autocorrelation?
No. Cross-correlation compares two sequences, while autocorrelation compares one sequence with a shifted version of itself.
Scroll to Top