# linear perceptron algorithm with 3 training samples

So I am working on a linear perceptron algorithm problem that has 3 training samples. (2D space)

x1 = (1,3) class 1 (y1 = 1)

x2 = (3,2) class 2 (y2 = -1)

x3 = (4,1) class 2 (y2 = -1)


and the linear perceptron is initialized with a line with corresponding weight w(0) = [2,-1,1]^T = 2 - x + y = 0

What I am confused by is how to use the weight . update rule to find the new weight w(1) based on the misclassified initial sample.

By perceptron update rule, we have $$w(t+1)=w(t)+(y_i-f(x_i))x_i$$ First update will use the pair $$(x_1,y_1)$$. $$f(x)$$ will depend on your choice. Some examples use hard-limiter or sign functions for simplicity. For example, if it is $$sgn(x)$$, then $$f(x_1)=sgn(2-1+3)=1$$, which is correct and weights stay the same, i.e. $$w(1)=w(0)$$. But for $$x_2$$, we have $$f(x_2)=sgn(2-3+2)=1$$, which is wrong and therefore weights are updated as follows: $$w(2)=w(1)+(-1-1)x_2=\begin{bmatrix}0& -7& -3\end{bmatrix}$$ It goes on like this. Some sources also use a learning rate, but it's not required.