%nagenerujeme si data tak, aby byla linearne zavisla
x=1:20;
y=1:20;

%pouzijeme funkci poissrnd, ktera nageneruje data s poissonovskym rozdelenim
ySum=poissrnd(y);

%napocitame Sk a Tk (slozky matice a prave strany)
S0=sum(x.^0);
S1=sum(x.^1);
S2=sum(x.^2);
T0=sum(ySum.*x.^0);
T1=sum(ySum.*x.^1);

%napocitame parametry a a b (reseni linearniho systemu)
b=(S2*T0-S1*T1)/(S0*S2-S1^2);
a=(S0*T1-S1*T0)/(S0*S2-S1^2);

%nagenerujeme si body x, ve kterych chceme provest interpolaci
xToPrint=1:0.1:20;

%spocteme si hodnotu interpolace
yToPrint=a*xToPrint+b;

%zobrazime
plot(x,ySum,'rx',xToPrint,yToPrint,'b-');

