11/16/2016
Regresi Linier
procedure TForm1.Button1Click(Sender: TObject);
var
B:Array[0..100] of real;
i:Integer; j:Real;
begin
ListBox1.Items.Add(Edit1.Text);
ListBox2.Items.Add(Edit2.Text);
Edit1.Clear;
Edit2.Clear;
j:=0;
for i:=0 to listbox2.count-1 do
begin
B[i]:=StrToFloat(Listbox2.Items[i]);
j:=j+B[i];
end;
Edit7.Text:=FloatToStr(j);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
A,AD,B,XY,M:Array[0..100] of Real;
i,n:Integer;
rerata,j,jml,a1,a0,j1,j2,j3:Real;
begin
n:=ListBox1.Items.Count;
For i:=0 to ListBox1.Items.Count-1 do
A[i]:=StrToFloat(ListBox1.Items[i]);
jml:=0;
For i:=0 to ListBox1.Items.Count-1 do
jml:=jml+A[i];
Edit4.Text:=FloatToStr(jml);
rerata:=jml/n;
Edit3.Text:=FloatToStr(rerata);
j1:=0;
j2:=0;
j3:=0;
j:=StrToFloat(Edit7.Text);
for i:=0 to listbox1.items.Count-1 do
begin
M[i]:=a[i]-rerata;
ListBox3.Items.Add(FloatToStr(m[i]));
j1:=j1+m[i];
Edit4.Text:=FloatToStr(j1);
AD[i]:=sqr(m[i]);
ListBox4.Items.Add(FloatToStr(AD[i]));
j2:=j2+AD[i];
Edit5.Text:=FloatToStr(j2);
B[i]:=StrToFloat(Listbox2.Items[i]);
XY[i]:=B[i]*M[i];
ListBox6.Items.Add(FloatToStr(XY[i]));
j3:=j3+XY[i];
Edit6.Text:=FloatToStr(j3);
a0:=(j*j2)-(j1*j3)/(n*j2);
Edit8.Text:=FloatToStr(a0);
a1:=(n*j3)/(n*j2);
Edit9.Text:=FloatToStr(a1);
end;
end;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment