Pseudorandom binary sequence

From HandWiki
Short description: Seemingly random, difficult to predict bit stream created by a deterministic algorithm

A pseudorandom binary sequence (PRBS), pseudorandom binary code or pseudorandom bitstream is a binary sequence that, while generated with a deterministic algorithm, is difficult to predict[1] and exhibits statistical behavior similar to a truly random sequence. PRBS generators are used in telecommunication, such as in analog-to-information conversion,[2] but also in encryption, simulation, correlation technique and time-of-flight spectroscopy. The most common example is the maximum length sequence generated by a (maximal) linear feedback shift register (LFSR). Other examples are Gold sequences (used in CDMA and GPS), Kasami sequences and JPL sequences, all based on LFSRs.

In telecommunications, pseudorandom binary sequences are known as pseudorandom noise codes (PN or PRN codes) due to their application as pseudorandom noise.


A binary sequence (BS) is a sequence [math]\displaystyle{ a_0,\ldots, a_{N-1} }[/math] of [math]\displaystyle{ N }[/math] bits, i.e.

[math]\displaystyle{ a_j\in \{0,1\} }[/math] for [math]\displaystyle{ j=0,1,...,N-1 }[/math].

A BS consists of [math]\displaystyle{ m=\sum a_j }[/math] ones and [math]\displaystyle{ N-m }[/math] zeros.

A BS is a pseudorandom binary sequence (PRBS) if[3] its autocorrelation function, given by

[math]\displaystyle{ C(v)=\sum_{j=0}^{N-1} a_ja_{j+v} }[/math]

has only two values:

[math]\displaystyle{ C(v)= \begin{cases} m, \mbox{ if } v\equiv 0\;\; (\mbox{mod}N)\\ \\ mc, \mbox{ otherwise } \end{cases} }[/math]


[math]\displaystyle{ c=\frac{m-1}{N-1} }[/math]

is called the duty cycle of the PRBS, similar to the duty cycle of a continuous time signal. For a maximum length sequence, where [math]\displaystyle{ N = 2^k - 1 }[/math], the duty cycle is 1/2.

A PRBS is 'pseudorandom', because, although it is in fact deterministic, it seems to be random in a sense that the value of an [math]\displaystyle{ a_j }[/math] element is independent of the values of any of the other elements, similar to real random sequences.

A PRBS can be stretched to infinity by repeating it after [math]\displaystyle{ N }[/math] elements, but it will then be cyclical and thus non-random. In contrast, truly random sequence sources, such as sequences generated by radioactive decay or by white noise, are infinite (no pre-determined end or cycle-period). However, as a result of this predictability, PRBS signals can be used as reproducible patterns (for example, signals used in testing telecommunications signal paths).[4]

Practical implementation

Pseudorandom binary sequences can be generated using linear-feedback shift registers.[5]

Some common[6][7][8][9][10] sequence generating monic polynomials are

PRBS7 = [math]\displaystyle{ x^{7} + x^{6} + 1 }[/math]
PRBS9 = [math]\displaystyle{ x^{9} + x^{5} + 1 }[/math]
PRBS11 = [math]\displaystyle{ x^{11} + x^{9} + 1 }[/math]
PRBS13 = [math]\displaystyle{ x^{13} + x^{12} + x^{2} + x + 1 }[/math]
PRBS15 = [math]\displaystyle{ x^{15} + x^{14} + 1 }[/math]
PRBS20 = [math]\displaystyle{ x^{20} + x^{3} + 1 }[/math]
PRBS23 = [math]\displaystyle{ x^{23} + x^{18} + 1 }[/math]
PRBS31 = [math]\displaystyle{ x^{31} + x^{28} + 1 }[/math]

An example of generating a "PRBS-7" sequence can be expressed in C as

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
int main(int argc, char* argv[]) {
    uint8_t start = 0x02;
    uint8_t a = start;
    int i;    
    for (i = 1;; i++) {
        int newbit = (((a >> 6) ^ (a >> 5)) & 1);
        a = ((a << 1) | newbit) & 0x7f;
        printf("%x\n", a);
        if (a == start) {
            printf("repetition period is %d\n", i);

In this particular case, "PRBS-7" has a repetition period of 127 values.

A more generalized code for any PRBS-k sequence up to k=32 using C++ templates can be found on GitHub.


The PRBSk or PRBS-k notation (such as "PRBS7" or "PRBS-7") gives an indication of the size of the sequence. [math]\displaystyle{ N = 2^k - 1 }[/math] is the maximum number[4]:§3 of bits that are in the sequence. The k indicates the size of a unique word of data in the sequence. If you segment the N bits of data into every possible word of length k, you will be able to list every possible combination of 0s and 1s for a k-bit binary word, with the exception of the all-0s word.[4]:§2 For example, PRBS3 = "1011100" could be generated from [math]\displaystyle{ x^{3} + x^{2} + 1 }[/math].[6] If you take every sequential group of three bit words in the PRBS3 sequence (wrapping around to the beginning for the last few three-bit words), you will find the following 7 word arrangements:

  "1011100" → 101
  "1011100" → 011
  "1011100" → 111
  "1011100" → 110
  "1011100" → 100
  "1011100" → 001 (requires wrap)
  "1011100" → 010 (requires wrap)

Those 7 words are all of the [math]\displaystyle{ 2^k - 1 = 2^3 - 1 = 7 }[/math] possible non-zero 3-bit binary words, not in numeric order. The same holds true for any PRBSk, not just PRBS3.[4]:§2

See also


  1. "PRBS Pseudo Random Bit Sequence Generation". 
  2. Daponte, Pasquale; De Vito, Luca; Iadarola, Grazia; Rapuano, Sergio. "PRBS non-idealities affecting Random Demodulation Analog-to-Information Converters". 
  3. Naszodi, Laszlo. "Articles on Correlation and Calibration". 
  4. 4.0 4.1 4.2 4.3 "ITU-T Recommendation O.150". October 1992. 
  5. Paul H. Bardell, William H. McAnney, and Jacob Savir, "Built-In Test for VLSI: Pseudorandom Techniques", John Wiley & Sons, New York, 1987.
  6. 6.0 6.1 Tomlinson, Kurt (4 February 2015). "PRBS (Pseudo-Random Binary Sequence)". 
  7. Koopman, Philip. "Maximal Length LFSR Feedback Terms". 
  8. "What are the PRBS7, PRBS15, PRBS23, and PRBS31 polynomials used in the Altera Transceiver Toolkit?". 14 February 2013. 
  9. Riccardi, Daniele; Novellini, Paolo (10 January 2011). "An Attribute-Programmable PRBS Generator and Checker (XAP884)". Table 3:Configuration for PRBS Polynomials Most Used to Test Serial Lines. 
  10. "O.150 : General requirements for instrumentation for performance measurements on digital transmission equipment". 1997-01-06. 

External links