
14.06.2006, 14:54
|
|
Участник форума
Регистрация: 21.03.2006
Сообщений: 117
Провел на форуме: 629074
Репутация:
137
|
|
недавно надо было. Вот и стряпал.
Код:
procedure TForm1.korelExecute(Sender: TObject);
var i,j,jj,n:integer;
listitem:tlistitem;
sc:string;
begin
for i:=1 to 2000 do
begin
x[i]:=0;
p1[i]:=0;
p2[i]:=0;
p3[i]:=0;
end;
for j:=1 to 3 do for i:=1 to 3000 do px[j][i]:=0;
n:=form1.StringGrid3.RowCount-1;
for i := 1 to n do
if (form1.StringGrid3.Cells[2,i] <> '-') and (form1.StringGrid3.Cells[2,i] <> '') then
px[1][i]:=StrToInt(form1.StringGrid3.Cells[2,i]) else px[1][i]:=0;
for i := 1 to n do
if (form1.StringGrid3.Cells[3,i] <> '-') and (form1.StringGrid3.Cells[3,i] <> '') then
px[2][i]:=StrToInt(form1.StringGrid3.Cells[3,i]) else px[2][i]:=0;
for i := 1 to n do
if (form1.StringGrid3.Cells[4,i] <> '-') and (form1.StringGrid3.Cells[4,i] <> '') then
px[3][i]:=StrToInt(form1.StringGrid3.Cells[4,i]) else px[3][i]:=0;
for j:=1 to 8 do
begin
with form1.ListView1 do
begin
ListItem := Items.Add;ListItem.Caption :='';
for jj:=0 to 7 do ListItem.SubItems.Add('');
end;
end;
for j:=1 to 3 do
begin
for i:=1 to n do mx[j]:=mx[j]+px[j][i];
mx[j]:=mx[j]/(n);
end;
//Розрахунок середньоквадратичного відхилення//
for j:=1 to 3 do
begin
s[j]:=0;
for i:=1 to n do s[j]:=s[j]+sqr(px[j][i]-mx[j]);
s[j]:=s[j]/(n-1);
sigma[j]:=sqrt(s[j]);
end;
for j:=1 to 3 do
begin
form1.ListView1.Items.Item[j-1].caption:=inttostr(j);
for jj:=1 to 3 do
begin
r[j,jj]:=0;
for i:=1 to n do
r[j,jj]:=r[j,jj]+((px[j][i]-mx[j])*(px[jj][i]-mx[jj]));
r[j,jj]:=r[j,jj]/((n-1)*sigma[j]*sigma[jj]);
str(r[j,jj]:5:8,sc);
form1.ListView1.Items.Item[j-1].SubItems[jj-1]:=sc;
end;
end;
end;
Вот кусок кода для Delphi. Если что не понятно, то стучи.
|
|
|