Rabu, 14 Desember 2011

Program Standar Deviasi

program stat_desk;
uses wincrt;
var
n,i,jml,s,j,c: integer;
a: array [1..50] of integer;
varians,mean,sd,selisih,sigma,y:real;


begin
write ('jml data: ');
readln (n);

i:=1;
repeat write ('data ke-',i,': ');
readln (a[i]);
jml:=jml+a[i];
inc (i);
until i>n;

writeln ('jumlah: ',jml);
mean:=jml/n;
writeln ('mean: ',mean:2:2);

i:=1;
repeat selisih:=sqr (a[i]-mean);
sigma:=sigma+selisih;
inc(i);
until i>n;
varians:= sigma/(n-1);
sd:=sqrt (varians);

writeln ('varians: ',varians:2:2);
writeln ('st.dev: ',sd:2:2);

{mengurutkan data}

for i:=1 to (n-1) do
begin
for j:=i+1 to n do
begin
if a[i] > a[j] then
begin
s:=a[i];
a[i]:=a[j];
a[j]:=s;
end;
end;
end;

for i:=1 to n do writeln (a[i]);


end.

Tidak ada komentar:

Posting Komentar