Смекни!
smekni.com

Вероятностные процессы и математическая статистика в автоматизированных системах (стр. 4 из 5)

minim:=fy(i/10,j/10,w/10);xlocmin[1]:=i/10;

xlocmin[2]:=j/10; xlocmin[3]:=w/10; end;

end;

ylocmin:=minim;

ylocmax:=maxim;

end;

procedure minmax;

type arr=array [1..3,1..3] of real;

var d,d1,d2,d3:arr; i:integer; bd:mas;

function delta(a:arr):real;

begin delta:=a[1,1]*(a[2,2]*a[3,3]-a[2,3]*a[3,2])-

a[1,2]*(a[2,1]*a[3,3]-a[2,3]*a[3,1])+

a[1,3]*(a[2,1]*a[3,2]-a[2,2]*a[3,1]); end;

begin d[1,1]:=2*b[7]; d[1,2]:=b[4]; d[1,3]:=b[5];

d[2,1]:=b[4]; d[2,2]:=2*b[8]; d[2,3]:=b[6];

d[3,1]:=b[5]; d[3,2]:=b[6]; d[3,3]:=2*b[9];

bd[1]:=-b[1]; bd[2]:=-b[2]; bd[3]:=-b[3];

for i:=1 to 3 do

begin d1[i,2]:=d[i,2]; d1[i,3]:=d[i,3];

d2[i,1]:=d[i,1]; d2[i,3]:=d[i,3];

d3[i,2]:=d[i,2]; d3[i,1]:=d[i,1];

d1[i,1]:=bd[i];d2[i,2]:=bd[i];d3[i,3]:=bd[i]; end;

xc[1]:=delta(d1)/delta(d);

xc[2]:=delta(d2)/delta(d);

xc[3]:=delta(d3)/delta(d);

ycen:=fy(xc[1],xc[2],xc[3]);

la[1]:=findl(-6,-2);

la[2]:=findl(-2,2);

la[3]:=findl(2,6);

for i:=1 to 3 do begin

ml[i]:=(b[6]*(b[7]-la[i])-0.5*b[4]*b[5])/(b[5]*(b[8]-la[i])-0.5*b[4]*b[6]);

nl[i]:=(-2*(b[7]-la[i])*(b[8]-la[i])+0.5*b[4]*b[4])/(b[5]*(b[8]-la[i])-0.5*b[4]*b[6]);

l[i]:=1/sqrt(1+sqr(ml[i])+sqr(nl[i]));

m[i]:=ml[i]*l[i];

n[i]:=nl[i]*l[i];

maximminim; end; end;

procedure TForm1.FormCreate(Sender: TObject);

var i,j:integer;

begin

x0[1]:=1; x0[2]:=175; x0[3]:=4;

ix[1]:=0.5; ix[2]:=25; ix[3]:=2;

y[1,1]:=24.99; y[1,2]:=22.61;y[1,3]:=26.99; y[1,4]:=39.61;

y[1,5]:=49.8; y[1,6]:=37.8; y[1,7]:=26.61; y[1,8]:=28.99;

y[1,9]:=35.8; y[1,10]:=37.61;y[1,11]:=27.99;y[1,12]:=24.18;

y[1,13]:=26.8; y[1,14]:=34.99;y[1,15]:=32.8;

y[2,1]:=25.51;y[2,2]:=23.89; y[2,3]:=26.89; y[2,4]:=39.51;

y[2,5]:=53.7; y[2,6]:=37.51; y[2,7]:=26.7; y[2,8]:=28.7;

y[2,9]:=38.89;y[2,10]:=37.32;y[2,11]:=33.51;y[2,12]:=28.7;

y[2,13]:=30.7; y[2,14]:=38.7;y[2,15]:=31.51;

xc2:=sqrt(8/15); d:=sqrt((15*xc2-8)/2);

ys:=y;

sgcod.Cells[0,1]:='Íóëåâîé óðîâåíü';

sgcod.Cells[0,2]:='Èíòåðâàë âàðüèðîâàíèÿ';

sgcod.Cells[0,3]:='Íèæíèé óðîâåíü';

sgcod.Cells[0,4]:='Âåðõíèé óðîâåíü';

sgcod.Cells[0,5]:='Êîäîâîå îáîçíà÷åíèå';

sgcod.Cells[1,0]:='Ñîäåðæ. Li,% ';

sgcod.Cells[2,0]:='T ñòàð., ãð.Ñ ';

sgcod.Cells[3,0]:=' t ñòàð., ÷. ';

for i:=1 to 3 do

begin sgcod.Cells[i,1]:=' '+floattostr(x0[i]);

sgcod.Cells[i,2]:=' '+floattostr(ix[i]);

sgcod.Cells[i,3]:=' '+floattostr(x0[i]-ix[i]);

sgcod.Cells[i,4]:=' '+floattostr(x0[i]+ix[i]);

end;

sgcod.Cells[1,5]:=' x1';

sgcod.Cells[2,5]:=' x2';

sgcod.Cells[3,5]:=' x3';

sgplan.Cells[1,0]:=' x0'; sgplan.Cells[2,0]:=' x1';

sgplan.Cells[3,0]:=' x2'; sgplan.Cells[4,0]:=' x3';

sgplan.Cells[5,0]:='x1^2-'+floattostrf(xc2,fffixed,3,2);

sgplan.Cells[6,0]:='x2^2-'+floattostrf(xc2,fffixed,3,2);

sgplan.Cells[7,0]:='x3^2-'+floattostrf(xc2,fffixed,3,2);

sgplan.Cells[8,0]:='x1x2'; sgplan.Cells[9,0]:='x1x3';

sgplan.Cells[10,0]:='x2x3'; sgplan.Cells[11,0]:=' y1';

sgplan.Cells[12,0]:=' y2'; sgplan.Cells[13,0]:=' yc';

for i:=1 to 15 do begin

if i<=8 then begin

if i mod 2 = 0 then x[1,i]:=1 else x[1,i]:=-1;

if ((i+1) div 2) mod 2 = 0 then x[2,i]:=1 else x[2,i]:=-1;

if ((i+3) div 4) mod 2 = 0 then x[3,i]:=1 else x[3,i]:=-1;

end

else begin

for j:=1 to 3 do

if i=7+2*j then x[j,i]:=-d

else if i=8+2*j then x[j,i]:=d

else x[j,i]:=0;

end;

x12[i]:=x[1,i]*x[2,i];

x23[i]:=x[2,i]*x[3,i];

x13[i]:=x[1,i]*x[3,i];

x[4,i]:=x12[i]; x[5,i]:=x13[i];

x[6,i]:=x23[i];

x[0,i]:=1;

for j:=1 to 3 do

x2[j,i]:=sqr(x[j,i])-xc2;

x[7,i]:=x2[1,i];

x[8,i]:=x2[2,i];

x[9,i]:=x2[3,i];

end;

for i:=1 to 15 do

begin sgplan.Cells[0,i]:=inttostr(i);

sgplan.Cells[1,i]:=' 1';

for j:=1 to 3 do begin

sgplan.Cells[j+1,i]:=' '+floattostr(x[j,i]);

sgplan.Cells[j+4,i]:=' '+floattostrf(x2[j,i],fffixed,5,3); end;

sgplan.Cells[8,i]:=' '+floattostr(x12[i]);

sgplan.Cells[9,i]:=' '+floattostr(x13[i]);

sgplan.Cells[10,i]:=' '+floattostr(x23[i]);

end;

xh[1]:=-1; xh[2]:=-1; xh[3]:=-1;

kk:=0;

end;

procedure TForm1.Button2Click(Sender: TObject);

var i:integer;

begin

kk:=kk+1;

for i:=1 to 15 do

sgplan.Cells[10+kk,i]:=floattostr(ys[kk,i]);

if kk>=2 then begin button2.Enabled:=false;

for i:=1 to 15 do begin

yc[i]:=(y[1,i]+y[2,i])/2;

ycs[i]:=(y[1,i]+y[2,i])/2;

sgplan.Cells[13,i]:=floattostr(ycs[i]);

end;

end;

end;

procedure TForm1.Button1Click(Sender: TObject);

var k1,k2:integer; yk:real;

begin

randomize;

k1:=random(14)+1;

k2:=random(14)+1;

sgplan.Rows[16]:=sgplan.Rows[k1];

sgplan.Rows[k1]:=sgplan.Rows[k2];

sgplan.Rows[k2]:=sgplan.Rows[16];

yk:=ys[1,k1];

ys[1,k1]:=ys[1,k2];

ys[1,k2]:=yk;

yk:=ys[2,k1];

ys[2,k1]:=ys[2,k2];

ys[2,k2]:=yk;

end;

procedure TForm1.PageControl1Change(Sender: TObject);

var u,i,j,li:integer; sums,g,s2ad,fp,xx:real;

begin

if button2.Enabled=false then begin

sgvos.Cells[0,0]:=' u';

sgvos.Cells[1,0]:=' S2u';

sums:=0;

for u:=1 to 15 do

begin s2u[u]:=sqr(yc[u]-y[1,u])+sqr(yc[u]-y[2,u]);

sgvos.Cells[1,u]:=floattostrf(s2u[u],fffixed,5,3);

sgvos.Cells[0,u]:=inttostr(u);

sums:=sums+s2u[u];

end;

s2umax:=s2u[1];

for i:=1 to 15 do

if s2u[i]>s2umax then s2umax:=s2u[i];

label5.Caption:=floattostrf(s2umax,fffixed,7,3);

g:=s2umax/sums;

label7.Caption:=floattostrf(g,fffixed,7,3);

label9.Caption:=floattostrf(0.47,fffixed,7,3);

if g<=0.47 then begin

label10.Caption:=' Îïûòû'+#13+'âîñïðîèçâîäèìû';

s2y:=0;

for i:=1 to 15 do

s2y:=s2y+s2u[i]/15;

if b[0]=0 then begin

for i:=0 to 9 do

b[i]:=sxy(i)/sx(i);

sgb.Cells[i,1]:=floattostrf(b[i],fffixed,5,3);

for j:=1 to 3 do

b[0]:=b[0]-b[6+j]*xc2;

sgb.Cells[0,1]:=floattostrf(b[0],fffixed,5,3);

sgb.Cells[0,0]:='b0'; sgb.Cells[1,0]:='b1';

sgb.Cells[2,0]:='b2'; sgb.Cells[3,0]:='b3';

sgb.Cells[4,0]:='b12'; sgb.Cells[5,0]:='b13';

sgb.Cells[6,0]:='b23'; sgb.Cells[7,0]:='b11';

sgb.Cells[8,0]:='b22'; sgb.Cells[9,0]:='b33';

for i:=0 to 9 do

begin s2b[i]:=s2y/(2*sx(i));

db[i]:=1.76*s2b[i];

sgsb.Cells[i+1,1]:=floattostrf(s2b[i],fffixed,7,3);

sgsb.Cells[i+1,2]:=floattostrf(db[i],fffixed,7,3);

end;

sgsb.Cells[1,0]:='b0'; sgsb.Cells[2,0]:='b1';

sgsb.Cells[3,0]:='b2'; sgsb.Cells[4,0]:='b3';

sgsb.Cells[5,0]:='b12'; sgsb.Cells[6,0]:='b13';

sgsb.Cells[7,0]:='b23'; sgsb.Cells[8,0]:='b11';

sgsb.Cells[9,0]:='b22'; sgsb.Cells[10,0]:='b33';

sgsb.Cells[0,1]:='S2bi'; sgsb.Cells[0,2]:='|bi|';

label16.Caption:=floattostrf(s2y,fffixed,7,3);

label18.Caption:=floattostrf(1.76,fffixed,7,3);

label21.Caption:='Íåçíà÷èìûå êîýôôèöèåíòû:';

li:=0;

for i:=0 to 9 do

if abs(b[i])<=db[i] then begin

li:=li+1;

label21.Caption:=label21.Caption+' b['+

inttostr(i)+']='+floattostrf(b[i],fffixed,7,4);

b[i]:=0;

end;

s2ad:=0;

for i:=1 to 15 do

s2ad:=s2ad+sqr(yc[i]-f(i))+2/(li*15);

fp:=s2ad/s2y;

label12.Caption:=floattostrf(s2y,fffixed,7,3);

label20.Caption:=floattostrf(s2ad,fffixed,7,3);

label25.Caption:=floattostrf(2.96,fffixed,7,3);

label26.Caption:=floattostrf(fp,fffixed,7,3);

if fp<=2.96 then

label27.Caption:=' Ìîäåëü àäåêâàòíà'

else

label27.Caption:=' Ìîäåëü íå àäåêâàòíà';

minmax;

memo2.lines.add('Êîîðäèíèòû öåíòðà ïîâåðõíîñòè');

memo2.lines.add(' xc1='+floattostrf(xc[1],fffixed,5,3)+

' xc2='+floattostrf(xc[2],fffixed,5,3)+

' xc3='+floattostrf(xc[3],fffixed,5,3)+

' yc='+floattostrf(ycen,fffixed,5,3) );

if ((la[1]<0) and (la[2]<0) and (la[3]<0)) or

((la[1]>0) and (la[2]>0) and (la[3]>0))

then memo2.lines.add(' Ïîâåðõíîñòü, èìåþùàÿ ýêñòðåìóì')

else memo2.lines.add(' Ïîâåðõíîñòü òèïà ìèíèìàêñà');

memo2.lines.add(' Ëîêàëüíûé ýêñòðåìóì');

memo2.lines.add(' xmax1='+floattostrf(xlocmax[1],fffixed,5,1)+

' xmax2='+floattostrf(xlocmax[2],fffixed,5,1)+

' xmax3='+floattostrf(xlocmax[3],fffixed,5,1)+

' Ymax='+floattostrf(ylocmax,fffixed,5,4));

memo2.lines.add(' xmin1='+floattostrf(xlocmin[1],fffixed,5,1)+

' xmin2='+floattostrf(xlocmin[2],fffixed,5,1)+

' xmin3='+floattostrf(xlocmin[3],fffixed,5,1)+

' Ymin='+floattostrf(ylocmin,fffixed,5,4));

end; end

else label10.Caption:=' Îïûòû íå'+#13+'âîñïðîèçâîäèìû';

for i:=0 to 9 do

sgb.Cells[i,1]:=floattostrf(b[i],fffixed,5,3);

end; end;

procedure TForm1.RadioGroup1Click(Sender: TObject);

var xxx:real;

begin series1.Clear; series2.Clear; series3.Clear;

case radiogroup1.ItemIndex of

0: begin groupbox7.Visible:=true;

label28.Caption:='x2='; label29.Caption:='x3=';

label30.Caption:='x2='; label31.Caption:='x3=';

label32.Caption:='x2='; label33.Caption:='x3=';

label34.Caption:='x1=';

xp2[1]:=strtofloat(edit1.text); xp3[1]:=strtofloat(edit2.text);

xp2[2]:=strtofloat(edit3.text); xp3[2]:=strtofloat(edit4.text);

xp2[3]:=strtofloat(edit5.text); xp3[3]:=strtofloat(edit6.text);

xxx:=-1;

while xxx<=1 do

begin series1.AddXY(xxx,fy(xxx,xp2[1],xp3[1]));

series2.AddXY(xxx,fy(xxx,xp2[2],xp3[2]));

series3.AddXY(xxx,fy(xxx,xp2[3],xp3[3]));

xxx:=xxx+0.01; end;

memo3.Clear;

memo3.Lines.Add('Ëèíèè ðåãðåññèè:');

memo3.Lines.Add('y= '+floattostrf(fy(0,xp2[1],xp3[1]),fffixed,4,2)+

' + '+floattostrf(b[1]+b[4]*xp2[1]+b[5]*xp3[1],fffixed,4,2)+

'*x1 + '+floattostrf(b[7],fffixed,4,2)+'*x1^2');

memo3.Lines.Add('y= '+floattostrf(fy(0,xp2[2],xp3[2]),fffixed,4,2)+

' + '+floattostrf(b[1]+b[4]*xp2[2]+b[5]*xp3[2],fffixed,4,2)+

'*x1 + '+floattostrf(b[7],fffixed,4,2)+'*x1^2');

memo3.Lines.Add('y= '+floattostrf(fy(0,xp2[3],xp3[3]),fffixed,4,2)+

' + '+floattostrf(b[1]+b[4]*xp2[3]+b[5]*xp3[3],fffixed,4,2)+

'*x1 + '+floattostrf(b[7],fffixed,4,2)+'*x1^2');

end;

1: begin groupbox7.Visible:=true;

label28.Caption:='x1='; label29.Caption:='x3=';

label30.Caption:='x1='; label31.Caption:='x3=';

label32.Caption:='x1='; label33.Caption:='x3=';

label34.Caption:='x2=';

xp1[1]:=strtofloat(edit1.text); xp3[1]:=strtofloat(edit2.text);

xp1[2]:=strtofloat(edit3.text); xp3[2]:=strtofloat(edit4.text);

xp1[3]:=strtofloat(edit5.text); xp3[3]:=strtofloat(edit6.text);

xxx:=-1;

while xxx<=1 do

begin series1.AddXY(xxx,fy(xp1[1],xxx,xp3[1]));

series2.AddXY(xxx,fy(xp1[2],xxx,xp3[2]));

series3.AddXY(xxx,fy(xp1[3],xxx,xp3[3]));

xxx:=xxx+0.01;

end;

memo3.Clear;

memo3.Lines.Add('Ëèíèè ðåãðåññèè:');

memo3.Lines.Add('y= '+floattostrf(fy(xp1[1],0,xp3[1]),fffixed,4,2)+

' + '+floattostrf(b[2]+b[4]*xp1[1]+b[6]*xp3[1],fffixed,4,2)+

'*x2 + '+floattostrf(b[8],fffixed,4,2)+'*x2^2');

memo3.Lines.Add('y= '+floattostrf(fy(xp1[2],0,xp3[2]),fffixed,4,2)+

' + '+floattostrf(b[2]+b[4]*xp1[2]+b[6]*xp3[2],fffixed,4,2)+

'*x2 + '+floattostrf(b[8],fffixed,4,2)+'*x2^2');

memo3.Lines.Add('y= '+floattostrf(fy(xp1[3],0,xp3[3]),fffixed,4,2)+

' + '+floattostrf(b[2]+b[4]*xp1[3]+b[6]*xp3[3],fffixed,4,2)+

'*x2 + '+floattostrf(b[8],fffixed,4,2)+'*x2^2');

end;

2: begin groupbox7.Visible:=true;

label28.Caption:='x1='; label29.Caption:='x2=';

label30.Caption:='x1='; label31.Caption:='x2=';

label32.Caption:='x1='; label33.Caption:='x2=';

label34.Caption:='x3=';

xp1[1]:=strtofloat(edit1.text); xp2[1]:=strtofloat(edit2.text);

xp1[2]:=strtofloat(edit3.text); xp2[2]:=strtofloat(edit4.text);

xp1[3]:=strtofloat(edit5.text); xp2[3]:=strtofloat(edit6.text);

xxx:=-1;

while xxx<=1 do

begin series1.AddXY(xxx,fy(xp1[1],xp2[1],xxx));

series2.AddXY(xxx,fy(xp1[2],xp2[2],xxx));

series3.AddXY(xxx,fy(xp1[3],xp2[3],xxx));

xxx:=xxx+0.01; end;

memo3.Clear;

memo3.Lines.Add('Ëèíèè ðåãðåññèè:');

memo3.Lines.Add('y= '+floattostrf(fy(xp1[1],xp2[1],0),fffixed,4,2)+

'+'+floattostrf(b[3]+b[5]*xp1[1]+b[6]*xp2[1],fffixed,4,2)+

x3 + '+floattostrf(b[9],fffixed,4,2)+'*x3^2');

memo3.Lines.Add('y= '+floattostrf(fy(xp1[2],xp2[2],0),fffixed,4,2)+

+ '+floattostrf(b[3]+b[5]*xp1[2]+b[6]*xp2[2],fffixed,4,2)+

x3 + '+floattostrf(b[9],fffixed,4,2)+'*x3^2');

memo3.Lines.Add('y= '+floattostrf(fy(xp1[3],xp2[3],0),fffixed,4,2)+

' + '+floattostrf(b[3]+b[5]*xp1[3]+b[6]*xp2[3],fffixed,4,2)+

'*x3 + '+floattostrf(b[9],fffixed,4,2)+'*x3^2'); end;

else groupbox7.Visible:=false;

end;

end;

procedure TForm1.RadioGroup2Click(Sender: TObject);

var px,yy,ymax,ymin:real;

xxx,xmax,xmin:mas;

begin series4.Clear; series5.Clear; series6.Clear;

px:=strtofloat(edit13.Text);

case radiogroup2.ItemIndex of

0:begin yy:=10; ymax:=0; ymin:=48;

label40.Caption:='x3=';

label41.Caption:='x1min='; label42.Caption:='x2min=';

label44.Caption:='x1max='; label45.Caption:='x2max=';

while yy<=48 do

begin xxx[1]:=-1;

while xxx[1]<=1 do

begin xxx[2]:=-1;

while xxx[2]<=1 do

begin if abs(fy(xxx[1],xxx[2],px)-yy)<=0.02

then series4.AddXY(xxx[1],xxx[2]);

if fy(xxx[1],xxx[2],px)<=ymin then

begin xmin[1]:=xxx[1]; xmin[2]:=xxx[2];

ymin:=fy(xxx[1],xxx[2],px);end;

if fy(xxx[1],xxx[2],px)>=ymax then

begin xmax[1]:=xxx[1]; xmax[2]:=xxx[2];

ymax:=fy(xxx[1],xxx[2],px);end;

xxx[2]:=xxx[2]+0.005; end;

xxx[1]:=xxx[1]+0.005; end;

yy:=yy+1.5; end;

series5.AddXY(xmax[1],xmax[2]); series6.AddXY(xmin[1],xmin[2]);