6 Haziran 2014 Cuma

randomfrom example

procedure TForm1.Button1Click(Sender: TObject);
var
data:array of string;
i,n,k:integer;
x:string;
begin
n:=memo1.lines.Count;
SetLength(data,n);
 for i:=0 to n-1 do
 begin
 data[i]:=(memo1.lines[i]);
 k:=strtoint(edit1.text);
 end;
 randomize;
  for i:=1 to k do
  begin
  x:=RandomFrom(data);
  memo2.lines.add(x);
  end;
end;

end.



momentskewkurtosis procedure

procedure TForm1.Button1Click(Sender: TObject);
var
mu,sigma:extended;
n,i:integer;
x:double;
begin
memo1.Clear;
randomize;
mu:=strtofloat(edit1.text);
sigma:=strtofloat(edit2.text);
n:=strtoint(edit3.text);
 for i:=0 to n-1 do
 begin
 x:=RandG(mu,sigma);
 memo1.Lines.Add(formatfloat('0.000',x));
 end;
 end;

procedure TForm1.RadioButton1Click(Sender: TObject);
var
m1,m2,m3,m4,ck,bk:extended;
data:array of double;
k,i:integer;
begin
k:=memo1.lines.Count;
setlength(data,k);
for i:=0 to k-1 do
 begin
  data[i]:=strtofloat(memo1.lines[i]);
  MomentSkewKurtosis(data,m1,m2,m3,m4,ck,bk);
 end;
 if radiobutton1.Checked then
 begin
 memo2.Lines.add('orjine göre 1.moment='+formatfloat('0.000',m1));
 end
 else if radiobutton2.Checked then
 begin
 memo2.Lines.add('orjine göre 2.moment='+formatfloat('0.000',m2));
 end
 else if radiobutton3.Checked then
 begin
 memo2.Lines.add('orjine göre 3.moment='+formatfloat('0.000',m3));
 end
 else if radiobutton4.Checked then
 begin
 memo2.Lines.add('orjine göre 4.moment='+formatfloat('0.000',m4));
 end
 else if radiobutton5.Checked then
 begin
 memo2.Lines.add('carpıklık katsayısı='+formatfloat('0.000',ck));
 end
 else if radiobutton6.Checked then
 begin
 memo2.Lines.add('basıklık katsayısı='+formatfloat('0.000',bk));
 end;
end;

end.

confidence interval...(randg,progressbar,array of double,extended)

procedure TForm1.Button1Click(Sender: TObject);
var
 mu,sigma:extended;
 i,n:integer;
 x:array of double;
 xbar,s,se,alt,ust,tablo:real;
begin
 Randomize;
 memo1.clear;
 mu:=strtofloat(edit1.text);
 sigma:=strtofloat(edit2.text);
 n:=strtoint(edit3.text);
 SetLength(x,n);
 ProgressBar1.Max:=n;
for i:=0 to n-1 do
begin
  x[i]:=RandG(mu,sigma);
  memo1.Lines.add(floattostr(x[i]));
  ProgressBar1.Position:=i+1;
end;
 xbar:=mean(x);
 s:=stddev(x);
 se:=s/sqrt(n);
 tablo:=strtofloat(edit4.text);
 alt:=xbar-(se*tablo);
 ust:=xbar+(se*tablo);
 edit5.text:=floattostr(alt);
 edit6.text:=floattostr(ust);
 memo2.Lines.add(formatfloat('0.000',alt)+';'+formatfloat('0.000',ust));
end;

end.




Randg fonksiyonu (randg function example) ile rastgele veri üretmek.

procedure TForm1.Button1Click(Sender: TObject);
var
 mu,sigma:Extended;
 i,n:integer;
 x:double;
begin
 randomize;
 mu:=strtoint(edit1.text);
 sigma:=strtoint(edit2.Text);
 n:=strtoint(edit3.text);
  for i:=0 to n-1 do
  begin
   x:=randg(mu,sigma);
   memo1.lines.add(formatfloat('0.###',x));
  end;
end;

end.



3 Haziran 2014 Salı

Stringgrid,button example. Colcount,Row Count

procedure TForm1.Button1Click(Sender: TObject);
var
r,c,j,i:integer;
begin
r:=strtoint(edit1.text);
c:=strtoint(edit2.text);
StringGrid1.ColCount:=c+1;
StringGrid1.RowCount:=r+1;
for i:=1 to c do
 begin
  for j:=1 to r  do
  begin
  if (i+j)>r+2  StringGrid1.Cells[i,j]:=inttostr((i+j)-1);
  end;
 end;
end;
end.