Anda di halaman 1dari 2

gmacro

normal_ss

erase c1-c200
erase k1-k200
note RANDOM VARIATE GENERATOR DISTRIBUSI NORMAL
note METODE SLICE SAMPLING
note MASUKKAN JUMLAH DATA (N) YANG AKAN DIBANGKITKAN
set c5;
file 'terminal';
NObs 1.
let k5=c5(1)
name c5 'DATA (N)'
# k5 = N
note
note MASUKKAN NILAI 'MU' YANG DIINGINKAN
set c6;
file 'terminal';
nobs 1.
let k6=c6(1)
name c6 'MU'
# k6 = mu
note
note MASUKKAN NILAI 'SIGMA' YANG DIINGINKAN
set c7;
file 'terminal';
nobs 1.
let k7=c7(1)
name c7 'SIGMA'
# k7 = sigma
note
note SEDANG PROSES, MOHON TUNGGU SEBENTAR...
note
note .......
note
# menentukan batas bawah dan batas atas untuk distribusi normal
let k105=k6-6*k7 #inisialisasi batas bawah sumbu x
let k106=k6+6*k7 #inisialisasi batas atas sumbu x

let k10=0

# PROSES SLICE SAMPLING

do k1=1:k5

# bangkitkan uniform dg batas atas dan bawah distr normal (horisontal)


random 1 c1;
uniform k105 k106.
name c1 'RANDOM_1'

let k10=k10+1

# menulis ke kolom c2(n)=Xn


let c2(k10)=c1
name c2 'NORMAL'

# pdf normal f(Xn)


let k2=exp(-0.5*((c1-k6)/k7)^2)/(k7*sqrt(2*pi()))
# random vertikal
random 1 c4;
uniform 0 k2.
name c4 'RANDOM_2'

# batas bawah dan atas sumbu x setelah random vertikal


let k105=k6-k7*sqrt(-2*ln(c4*k7*sqrt(2*pi())))
let k106=k6+k7*sqrt(-2*ln(c4*k7*sqrt(2*pi())))

# mendokumentasikan proses
let c10(k10)=k2
name c10 'f(x)'
let c11(k10)=c4(1)
name c11 'Vert_Rand'
let c12(k10)=k105
name c12 'Lower_Bound'
let c13(k10)=k106
name c13 'Upper_Bound'

enddo

# pengecekan hasil dengan stat deskriptif dan histogram


describe c2;
mean;
count;
stdeviation;
variance;
gnhistogram.

# pengujian hasil dengan normal tes kolmogorov smirnov


normtest c2;
kstest.

# pengujian hasil dengan empirical cdf


ECDF C2;
Connect;
Distribution;
HParameters K6 K7.

# pengujian hasil dengan Individual Distribution Identification


DCapa c2;
Normal;
RDescriptive;
RFitTests;
REstimate.

endmacro

Anda mungkin juga menyukai