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.



28 Mayıs 2014 Çarşamba

list of integers,square of integers,square root of integers,stringgrid,progressbar example

procedure TForm1.Button1Click(Sender: TObject);
var
 a,b,j,k:integer;
begin
 a:=strtoint(edit1.text);
 b:=strtoint(edit2.text);
 StringGrid1.RowCount:=(b-a+1)+1;
  for j:=1 to stringgrid1.RowCount-1 do
   StringGrid1.Cells[0,j]:=inttostr(j);
  j:=0;
  ProgressBar1.Max:=b-a+1;
  if RadioButton1.Checked then
   begin
    for k:=a to b do
    begin
    inc(j);
    StringGrid1.Cells[1,j]:=inttostr(k);
    ProgressBar1.Position:=j;
    end;
   end
  else if RadioButton2.Checked then
   begin
    for k:=a to b do
    begin
    inc(j);
    StringGrid1.Cells[1,j]:=inttostr(sqr(k));
    ProgressBar1.Position:=j;
    end;
   end
  else if RadioButton3.Checked then
   begin
    for k:=a to b do
    begin
    inc(j);
    StringGrid1.Cells[1,j]:=floattostr(sqrt(k));
    ProgressBar1.Position:=j;
    end;
   end;

end;
end.




16 Mayıs 2014 Cuma

Delphi 7 download,indir,torrent

BORLAND DELPHİ 7 buradan indirebilirsiniz...


Download Torrent Link



#soma

9 Mayıs 2014 Cuma

Kaç kez atılacığını kullanıcının belirleyeceği 2 zarın aynı anda atılması sonucunda sonuçları gösteren kod.

procedure TForm1.Button1Click(Sender: TObject);
var
 i,a,z1,z2:integer;
begin
 a:=strtoint(edit1.text);   // ' a ' kullanıcının girdiği zar atışının sayısı
 For i:=1 to a do
 begin
  z1:=randomrange(1,7);    //  randomrange komutunda alt sınır dahil fakat üst sınır dahil olmadığından 7 aldık
  z2:=RandomRange(1,7);
  memo1.lines.Add(inttostr(z1)+' '+inttostr(z2));
 end;
end;
end.



Rastgele veri üretmek,Normalizasyon yöntemi(min-max,z score)

ihtiyacımız olanlar ; button,2 tane memo, combobox

ilk olarak button1 ın onclick event'ına aşagıdaki kodları giriyoruz.

procedure TForm1.Button1Click(Sender: TObject);
var
 i:integer;
 x:real;
begin
 Memo1.Clear;
 Randomize;   // bu işlem sayesınde button'a her tıkladıgımızda farklı sayılar geliyo
 for i:=1 to 100 do          //örneklem geniligini kendimiz 100 olrak belirledik
 begin
  x:=Random*(10-0)+0;  //U(0,10);
  memo1.Lines.Add(Floattostr(x));
 end;
end;


Not: Randomrange tamsayılarda çalıştığı için burada Random kullanarak real sayılar elde etmeye çalıştık.
Örneklem büyüklüğü 100 olarak almamaza ragmen bir editbox koyarak kullanıcının girmesini sağlayabiliriz.

combobox1 in onchange event'ına aşagıdaki kodları giriyoruz ;

procedure TForm1.ComboBox1Change(Sender: TObject);
var
data,x:array of double;
n,i:integer;
min,max,xbar,std:real;
begin
 n:=memo1.Lines.Count;
 SetLength(data,n);
 SetLength(x,n);
 for i:=0 to n-1 do
  data[i]:=strtofloat(memo1.lines[i]);
 memo2.clear;
 if ComboBox1.ItemIndex=0 then
 begin
  min:=MinValue(data);
  max:=MaxValue(data);
   for i:=0 to n-1 do
    begin
    x[i]:=(data[i]-min)/(max-min);
    memo2.Lines.add(formatfloat('0.##0',x[i]));
    end;

 end
 else if ComboBox1.ItemIndex=1 then
 begin
   xbar:=Mean(data);
   std:=stddev(data);
    for i:=0 to n-1 do
     begin
      x[i]:=((data[i]-xbar)/std);
      memo2.Lines.add(formatfloat('0.##0',x[i]));

     end;
 end;
end;

end.





Bu kod da kullandığımız önemli sayılan kodlar aşağıda listelenmiştir.

 min:=MinValue();    //  minimum değeri bulur.
 max:=MaxValue();   //  maximum değeri bulur.
 xbar:=Mean();          //  ortalama bulur.
 std:=stddev();           //  Standart Sapmayı bulur.

7 Mayıs 2014 Çarşamba

memo1 e girilen sayıların En küçük,en büyük,toplam,toplamların karesini,ortalamasını,varyansını,std.sapmasını memo2 ye yazdıran program (radiobutton yardımı ile)

kodu radiobutton1 e yazıyoruz daha sonra diger radiobutton'lar onclick event'ine gelerek radiobutton1 i seçili yapıyoruz . Bu sayede her kodu teker teker radiobuttonlara yazmamıza gerek kalmıcak.


procedure TForm1.RadioButton1Click(Sender: TObject);
var
 data:array of double;
 i,n:integer;
 min,max,t,tt,m,v,s:real;
begin
 n:=memo1.lines.Count;
 SetLength(data,n);
 for i:=0 to n-1 do
  data[i]:=strtoint(memo1.Lines[i]);
 if RadioButton1.Checked then
 begin
  min:=Minvalue(data);
  memo2.Lines.Add('En Küçük'+' '+floattostr(min));
 end
 else if RadioButton2.Checked then
 begin
  max:=MaxValue(data);
  memo2.lines.Add('En Büyük'+' '+floattostr(max));
 end
 else if RadioButton3.Checked then
 begin
  t:=sum(data);
  memo2.lines.Add('Toplam'+' '+floattostr(t));
 end
 else if RadioButton4.Checked then
 begin
  tt:=SumOfSquares(data);
  memo2.lines.add('karelerinin Toplamı'+' '+floattostr(tt));
 end
 else if RadioButton5.Checked then
 begin
  m:=Mean(data);
  memo2.lines.Add('ortalama'+' '+floattostr(m));
 end
 else if RadioButton6.Checked then
 begin
  v:=variance(data);
  memo2.Lines.Add('varyans'+' '+floattostr(v));
 end
 else if RadioButton7.Checked then
 begin
  s:=Stddev(data);
  memo2.lines.add('Std.Sapma'+' '+floattostr(s));
 end;
 end;

end.






floattostr yerine bazı degısıkler yaparak ''formatfloat'' kullanabılır ayrıca '#.### veya #.##0' gibi çeşitler ile ortaya çıkan sonuçların ondalık kısmının kaç basamağının gözükmesini ayarlayabilirsiniz. İlerleyen yayınlarımda bunla ilgili örnek uygulamalı olarak göstercem.


23 Nisan 2014 Çarşamba

Listbox'a sayı ekleme,eklenen sayıların ortalamasını ve S.Sapma'sını bulma

procedure TForm1.Button1Click(Sender: TObject);
begin
listbox1.items.Add(edit1.text);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
x,i:integer;
t,stdev,toplam,mean:real;
begin
toplam:=0;
for i:=0 to listbox1.count-1 do
 begin
  x:=strtoint(listbox1.items[i]);
  toplam:=toplam+x;
  mean:=toplam/(listbox1.count);
  edit2.text:=floattostr(mean);
 end;
 t:=0;
     for i:=0 to listbox1.count-1 do
     begin
    x:=strtoint(listbox1.items[i]);
    t:=t+sqr(x-mean);
    end;
    stdev:=sqrt(t/(listbox1.Count-1));
     edit3.text:=floattostr(stdev);
end;

end.

Listbox özelliklerini basit bir örnekle anlatım.

procedure TForm1.Button1Click(Sender: TObject);
begin
listbox1.items.add(edit1.text);
end;

procedure TForm1.ListBox1Click(Sender: TObject);
var
i:integer;
begin
i:=listbox1.ItemIndex;
edit2.text:=listbox1.Items[i];
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
listbox1.DeleteSelected;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to listbox1.Count-1 do
 begin
  if listbox1.Selected[i] then
  listbox2.items.add(listbox1.items[i]);

 end;
 listbox1.DeleteSelected;
end;

end.



22 Nisan 2014 Salı

Sıcaklık Değerini Değiştirme [celcius to fahrenheit]

procedure TForm1.Button1Click(Sender: TObject);
var
a,yenideger:real;
begin
a:=strtofloat(edit1.text);
if radiobutton1.Checked then
yenideger:=((a)*(9/5))+32;
edit2.text:=floattostr(yenideger);
if radiobutton2.checked then
yenideger:=((a)-32)*(5/9);
edit2.text:=floattostr(yenideger);
end;

end.



Form'un rengini değiştirmek (radiobutton'lar kullanarak)

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
form1.Color:=clRed;
end;

procedure TForm1.RadioButton2Click(Sender: TObject);
begin
form1.color:=clGreen;
end;

procedure TForm1.RadioButton3Click(Sender: TObject);
begin
form1.color:=clBlue;
end;

procedure TForm1.RadioButton4Click(Sender: TObject);
begin
form1.color:=clBtnFace;
end;

end.



Basit Hesap Makinesi code

procedure TForm1.Button1Click(Sender: TObject);
var
a,b:integer;
c:real;
begin
a:=strtoint(edit1.text);
b:=strtoint(edit2.text);
if radiobutton1.Checked then
c:=a+b;
edit3.Text:=floattostr(c);
if radiobutton2.Checked then
c:=a-b;
edit3.Text:=floattostr(c);
if radiobutton3.Checked then
c:=a*b;
edit3.Text:=floattostr(c);
if radiobutton4.Checked then
c:=a/b;
edit3.Text:=floattostr(c);

end;

end.





Faktöriyel hesaplayan code

procedure TForm1.Button1Click(Sender: TObject);
var
carpim,n,i:integer;
begin
carpim:=1;
n:=strtoint(edit1.text);
  begin
   if n=0 then
   edit2.text:='1'
   else
     for i:=1 to n do
       begin
    carpim:=carpim*i;
    edit2.text:=inttostr(carpim);
       end;
   end;
end;

end.


1'den n'e kadar sayıların toplamını gösteren kod

procedure TForm1.Button1Click(Sender: TObject);
var
n,toplam,i:integer;
begin
toplam:=0;
n:=strtoint(edit1.text);
for i:=1 to n do
 begin
   toplam:=toplam+i;
   edit2.text:=inttostr(toplam);
 end;
end;

end.



1'den 10'a ve 10'dan 1'e kadar sayı yazdıran program kodu

procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=1 to 10 do
edit1.text:=edit1.text+' '+inttostr(i);
end;

procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
begin
for i:=10 downto 1 do
edit2.text:=edit2.text+' '+inttostr(i);
end;

end.

İki Sayıyı Karşılaştırma

procedure TForm1.Button1Click(Sender: TObject);
var
a,b:integer;
begin
a:=strtoint(edit1.text);
b:=strtoint(edit2.text);
 begin
  if a>b then showmessage('1.sayı büyüktür');
  if a  if a=b then showmessage('sayılar eşittir');
 end;
end;

end.