Macro minitab untuk metode slice sampling

26/03/2013 10:53

 

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 c102;
file 'terminal';
NObs 1.
let k102=c102(1)
name c102 'DATA (N)'
# k102 = N
note
note MASUKKAN NILAI 'MU' YANG DIINGINKAN
set c103;
file 'terminal';
nobs 1.
let k103=c103(1)
name c103 'MU'
# k103 = mu
note
note MASUKKAN NILAI 'SIGMA' YANG DIINGINKAN
set c104;
file 'terminal';
nobs 1.
let k104=c104(1)
name c104 'SIGMA'
# k104 = sigma
note
note SEDANG PROSES, MOHON TUNGGU SEBENTAR...
note
note .......
note
# menentukan batas bawah dan batas atas untuk distribusi normal
let k105=k103-6*k104 #inisialisasi batas bawah sumbu x
let k106=k103+6*k104 #inisialisasi batas atas sumbu x
 
let k10=0
 
# PROSES SLICE SAMPLING
 
do k1=1:k102
 
# 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-k103)/k104)^2)/(k104*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=k103-k104*sqrt(-2*ln(c4*k104*sqrt(2*pi())))
let k106=k103+k104*sqrt(-2*ln(c4*k104*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 K103 K104.
 
# pengujian hasil dengan Individual Distribution Identification
DCapa c2;
Normal; 
Exponential; 
Weibull; 
Gamma.
 
 
endmacro