(*nacitame si balik*)

<<"LinearRegression`"

(*V dvocho vodocetnych staniciach na rieke sa sledovali prietoky vody (xi,yi) vysledky su zaznamenane v tabulke ,vypocitajte koreleacny koeficient urcite mieru lin.yavislost*)

dataX={23.1 , 12.8,17.8,21.3,18.5,93.5};
dataY={25.9,15.1,20.4,23.5,21,105.9};

Covariance[dataX,dataY]

kor=((Covariance[dataX,dataY])/(StandardDeviation[dataX]*StandardDeviation[dataY]))

koreleacnykof=Correlation[dataX,dataY]

ListPlot[Table[{dataX[[i]] ,dataY[[i]]},{i,1,Length[dataX]}],PlotRange->All,Joined->True,PlotMarkers->Automatic]

data1={1,2,3,0,5,10,12,4,3,2,4,7,9,11,4,2,3,4,75,82,-12,1.1,2,35,2.3,6,-5,0,3};

data2={11,2,-3,10,5,1,2,-4,33,1.1,3.5,4,2,1,-9,3.3,4,77,-8,2,5.5,9,11,-2,2.2,7,-3,9,10};

Correlation[data1,data2]//N  (*to //N je tu preto bo nam napise cele cislo a nie v zlomkovom tvare*)

ListPlot[Table[{data1[[i]] ,data2[[i]]},{i,1,Length[data1]}],PlotRange->All,PlotStyle->PointSize[Large]]

TEstkorelacie[data1_,data2_,alpha_]:=
Module[{a},a=alpha;Print[Style["test nulovosti koreelacneho koeficienta",16,Bold]];
r=Correlation[data1,data2];n=Length[data1];
Print[Style["----------------",16,Bold]];
Print["korelacny koeficient ma hodnotu : ",r]; uu=((Abs[r]*(Sqrt[n-2]))/(1-r^2));
Print["test statisitka ma hodnotu ;" ,uu];
uuu=Quantile[StudentTDistribution[n-2],1-a/2];
Print["kvantil studentovho rozdeleinia je :" ,uuu];
Print[Style["----------------",16,Bold]];
Print[Style["zaver",16,Bold]];Print[Print[Style["----------------",16,Bold]];];
if[((Abs[r](Sqrt[n-2]))/(1-r^2))>uuu,Print["zamietam H,korelacny koeficient ni je nulovy"],Printf["nezmietam H0"]]]

TEstkorelacie[data1,data2,0.05]