Saturday, September 12, 2009

Some of Randomize Data Distribution

  • Uniform
Function Uniform (a,b : double) : double;
Var u : double;
Begin
u := random;
Uniform := (b-a) * u + a;
End;

  • Eksponensial
Function Eksponensial (beta : double) : double;
Var u : double;
Begin
u := random;
Eksponensial := -beta * ln(u);
End;

  • Normal

Procedure Normal (mean,variance : double ; Var z1,z2 : double);
Var u1,u2,v1,v2,w,y,x1,x2 : double;
Begin
Repeat
u1 := random;
u2 := random;
v1 := 2 * u1 – 1;
v2 := 2 * u2 – 1;
w := sqr(v1) + sqr(v2);
if w <= 1 then
begin
y := sqrt ((-2*ln(w))/w);
x1 := v1 * y;
x2 := v2 * y;
z1 := sqrt (variance) * x1 + mean;
z2 := sqrt (variance) * x2 + mean;
end
Until w <= 1;
End;

  • Lognormal

procedure lognormal (mean,varr : double;
Var zln1,zln2 : double);
Var y1, y2 : double;
begin
Normal (mean,varr,y1,y2);
zln1 := exp(y1);
zln2 := exp(y2);
end;

  • Weibull

Function Weibull (alfa,beta: double) : double;
Var u,z : double;
Begin
u := random;
z := -ln(u);
Weibull := beta * exp (ln(z)/alfa);
End;

  • t-student

function tdistribution(m:integer):double;

Label r2;
Var v,x,r,s,c,a,f,g,mm : real;
begin
mm:=0;
if m < 1 then
begin
writeln('impermissible degrees of freedom.');
halt;
end;
if (m mm) then
begin
s:=m;
c:=-0.25*(s+1);
a:=4/power((1+1/s),c);
f:=16/a;
if m>1 then
begin
g:=s-1;
g:=power(((s+1)/g),c)*sqrt((s+s)/g);
end else
g := 1;
mm:=m;
end;
r2:repeat
r:=random;
until r > 0.0;
x:=(2*random-1)*g/r;
v:=x*x;
if (v>(5-a*r)) then
begin
if ((m>=3) and (r*(v+3)>f)) then goto r2;
if (r>power((1+v/s),c)) then goto r2;
end;
tdistribution :=x;
end;

begin
tipe11[1]:=0.2;
tipe11[1]:=0.3;
tipe11[1]:=0.5;
tipe11[1]:=0.8;
tipe11[1]:=1.0;
end.

Launching CampuScape Album

"Sepuluh Nopember Institute of Tech in
Black and White Concept"




For More 'bout Campus Scape
See My DeviantArt Profile

==============================================================
================================================
=================================
=================

Pseudo-Random Generation Numbers

Generating random numbers or pseudo-random generation from pseudo word which means false or not true. So the pseudo-random sequence generation means that random numbers are still using the formula that was to be expected what would appear. So in pseudo-random generation is not truly random or pseudo random.

Example :



Where, Modulo is the remainder of the division of integers.
Based on the example above can be explained that the modulus is the remainder of the division, at X0 = 2 (4) modulus 5 = 3, 3 obtained from 2x4 = 8 divided by 5, the remainder of the division is 3.
Because of recurring random numbers, it is called Pseudo. So recurrence of a long random number, then made a huge m until (2^k)-1.
If m = 5 then the number that may arise is 0,1,2,3,4.

Binary
Binary is a number that only consists of 2 numbers, 0 and 1.
The largest binary digit 1 is 1 .
The largest binary number is 2 digits 11 = 3
Largest binary number is a 3-digit 111 = 7
Bilagan largest k-digit binary is 11 ... 1 = (2^k)-1
If the binary number more than 32 digits then the computer said to overflow.


Randomize Uniform Data
With these approaches we can use it to randomize data distributed Uniform (a,b).
With Packet Program Turbo Pascal we can use the function :

function uniform(a,b:real) : real;
begin
uniform:=a+(b-a)x random;
end;

Randomize Exponential Data
By using the pascal program can use the function :

function expo(mean:real) : real;
begin
uniform:=-log e (random) * mean;
end;

**) For those 2 Randomize distributed data we can Use another Program to prove it.
You can click my ads link for support and other statistics link.