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 and exhibits statistical behavior similar to a truly random sequence. PRBS generators are used in telecommunication, such as in analog-to-information conversion, 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.
Details
A binary sequence (BS) is a sequence <math>a_0,\ldots, a_{N-1}</math> of <math>N</math> bits, i.e.
:<math>a_j\in \{0,1\}</math> for <math>j=0,1,...,N-1</math>.
A BS consists of <math>m=\sum a_j</math> ones and <math>N-m</math> zeros.
A BS is a pseudorandom binary sequence (PRBS) if its autocorrelation function, given by
:<math>C(v)=\sum_{j=0}^{N-1} a_ja_{j+v}</math>
has only two values:
:<math>C(v)=
\begin{cases}
m, \mbox{ if } v\equiv 0\;\; (\mbox{mod}N)\\
\\
mc, \mbox{ otherwise }
\end{cases}</math>
where
:<math>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>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>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>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).
Practical implementation
Pseudorandom binary sequences can be generated using linear-feedback shift registers.
Some common sequence generating monic polynomials are
:PRBS7 = <math>x^{7} + x^{6} + 1</math>
:PRBS9 = <math>x^{9} + x^{5} + 1</math>
:PRBS11 = <math>x^{11} + x^{9} + 1</math>
:PRBS13 = <math>x^{13} + x^{12} + x^{2} + x + 1 </math>
:PRBS15 = <math>x^{15} + x^{14} + 1</math>
:PRBS20 = <math>x^{20} + x^{3} + 1</math>
:PRBS23 = <math>x^{23} + x^{18} + 1</math>
:PRBS31 = <math>x^{31} + x^{28} + 1</math>
An example of generating a "PRBS-7" sequence can be expressed in C as
<syntaxhighlight lang="c">
- 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);
break;
}
}
}
</syntaxhighlight>
In this particular case, "PRBS-7" has a repetition period of 127 values.
Notation
The PRBSk or PRBS-k notation (such as "PRBS7" or "PRBS-7") gives an indication of the size of the sequence. <math>N = 2^k - 1</math> is the maximum number
