Скачиваний:
21
Добавлен:
02.05.2014
Размер:
3.65 Кб
Скачать
uses crt, graph;
const N=100;
var i,j,gd,gm: integer;
x,hi2,d,c: real;
p: array[1..5] of real;
l: array[1..5] of integer;
q: array[1..N] of real;
g: string[8];
begin
randomize;
clrscr;
p[1]:=0.1;
p[2]:=0.25;
p[3]:=0.2;
p[4]:=0.4;
p[5]:=0.05;

hi2:=0;
c:=0;
for i:=1 to 5 do
l[i]:=0;

for i:=1 to N do begin
x:=random;
q[i]:=x;
c:=c+x;
j:=0;
d:=0;
repeat
j:=j+1;
d:=d+p[j];
until d>=x;
l[j]:=l[j]+1;
end;

for i:=1 to 5 do
hi2:=hi2+sqr(l[i]-N*p[i])/(N*p[i]);

initgraph(gd,gm,'d:\prog\f1.7\bgi');
setcolor(9);
moveto(10,10);
outtext('pj ');
for i:=1 to 5 do begin
str(p[i]:6:2,g);
outtext(g);
end;
moveto(10,25);
outtext('vj ');
for i:=1 to 5 do begin
str(l[i]:6,g);
outtext(g);
end;

outtextxy(10,60,'X^2 prinadlezit doveritelnomu intervalu (0,71<=X^2<=9,5)?');
outtextxy(10,70,'X^2 = ');
str(hi2:5:3,g);
outtextxy(60,70,g);
c:=c/N;
str(c:5:3,g);
outtextxy(10,400,'Empiricheskoe mat. ozidanie:');
outtextxy(10,410,'e~=');
outtextxy(40,410,g);
outtextxy(90,410,'(doverit. interval 0,444<=e~<=0,556)');
for i:=1 to N do
x:=x+sqr(q[i]-c);
x:=x/(N-1);
str(x:5:3,g);
outtextxy(10,420,'Empiricheskaya dispersiya:');
outtextxy(10,430,'s^2=');
outtextxy(50,430,g);
setcolor(14);
line(10,21,350,21);
line(40,10,40,35);

if (hi2>=0.71) and (hi2<=9.5) then
outtextxy(10,80,'da') else
outtextxy(10,80,'net');

line(50,110,50,340);
line(50,330,370,330);
line(46,115,50,110); line(50,110,54,115);
line(365,326,370,330); line(365,334,370,330);
outtextxy(100,100,'Funcii raspredeleniya');
setcolor(10);
d:=0;
for i:=1 to 5 do begin
line(round(300*d)+50,330-round(200*d),round(300*d)+50,330-round(200*(d+p[i])));
d:=d+p[i];
line(round(300*d)+50,330-round(200*d),round(300*(d-p[i]))+50,330-round(200*d));
setcolor(14);
line(round(300*d)+50,327,round(300*d)+50,333);
line(47,330-round(200*d),53,330-round(200*d));
str(d:3:2,g);
if i<>5 then outtextxy(round(300*d)+35,340,g);
outtextxy(10,327-round(200*d),g);
setcolor(6);
setlinestyle(1,0,2);
line(55,330-round(200*d),round(300*(d-p[i]))+50,330-round(200*d));
setlinestyle(0,0,1);
setcolor(10);
end;
line(10,330,50,330);

line(235,218,250,218);
setcolor(12);
line(235,228,250,228);

setcolor(14);
outtextxy(15,105,'F(x)');
outtextxy(373,337,'xj');
outtextxy(347,315,'1');
outtextxy(255,215,'teoretich. F(x)');
outtextxy(255,225,'experiment. F(x)');

setcolor(13);
line(420,130,420,330);
line(420,330,630,330);
line(417,135,420,130); line(423,135,420,130);
line(625,327,630,330); line(625,333,630,330);
outtextxy(390,328-N,'100');
outtextxy(375,120,'vj/pj');
outtextxy(610,335,'pj');

setcolor(9);
outtextxy(450,110,'Gistogramma chastot');
d:=0;
for i:=1 to 5 do begin
d:=d+p[i];
line(round(200*(d-p[i]))+420,330-round(l[i]/p[i]),
round(200*d)+420,330-round(l[i]/p[i]));
line(round(200*d)+420,330-round(l[i]/p[i]),
round(200*d)+420,330);
line(round(200*(d-p[i]))+420,330-round(l[i]/p[i]),
round(200*d)+420,330);
line(round(200*(d-p[i]))+420,330-round(l[i]/p[i]),
round(200*(d-p[i]))+420,330);
end;
setlinestyle(1,0,2);
setcolor(6);
line(419,330-N,630,330-N);
setlinestyle(0,0,1);

readln;

x:=0;
d:=0;
setcolor(12);
for i:=1 to 5 do begin
line(round(300*d)+50,330-round(200*x),round(300*d)+50,330-round(200*(x+l[i]/N)));
x:=x+l[i]/N;
d:=d+p[i];
line(round(300*d)+50,330-round(200*x),round(300*(d-p[i]))+50,330-round(200*x));
end;

readln;
closegraph;
end.
Соседние файлы в папке Modelup_q