# Barker sequence

Hi I am learning about Barker sequence. I have a problem, because I do not know, why for example 5, in Barker Code looks like this: +++-+. What is the base of this code. I am looking for some algorithm, because, I do not want to learn by hearth.

-

You should look at wikipedia.

There you will find the definition: "A Barker code is a sequence of N values of +1 and −1, $a_j$ for $j= 1, 2, ..., N$ such that

$$|\sum_{j=1}^{N-v} a_ja_{j+v}| \le 1$$

for all $1 \le v < N$."

The Barker code for 3 is given by $+1$ $+1$ $-1$, i.e $a_1 = +1$, $a_2 = +1$, $a_3 = -1$. Here you can check that the definition works: if $v = 1$ you have that

$$|\sum_{j=1}^{3-1} a_ja_{j+1}| = |\sum_{j=1}^{2} a_ja_{j+1}| = | a_1a_2 + a_2a_3| = |1\cdot 1 + 1 \cdot (-1)| = 0 \le 1$$

And for $v = 2$ you have:

$$|\sum_{j=1}^{3-2} a_ja_{j+2}| = |a_1a_3| = |1\cdot (-1)| \le 1$$

Hence $+1$ $+1$ $-1$ is a correct Barker code for $3$.

So in Barker code, 5 is given by the sequence $+1$ $+1$ $+1$ $−1$ $+1$. This is just a sequence of numbers that works given your definition. You can check this by computing the 4 sums.

-

As milcak said $1,1,1,-1,1$ satisfies the definition. You can also verify that the reversal of the sequence also works and the sequence obtained by multiplying the entire sequence by $-1$ also works.

-