-
Notifications
You must be signed in to change notification settings - Fork 0
/
hartigansdipsigniftest.m
35 lines (29 loc) · 1.31 KB
/
hartigansdipsigniftest.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function [dip, p_value, xlow,xup]=HartigansDipSignifTest(xpdf,sh,nboot)
% function [dip,p_value,xlow,xup]=HartigansDipSignifTest(xpdf,nboot)
%
% calculates Hartigan's DIP statistic and its significance for the empirical p.d.f XPDF (vector of sample values)
% This routine calls the matlab routine 'HartigansDipTest' that actually calculates the DIP
% NBOOT is the user-supplied sample size of boot-strap
% Code by F. Mechler (27 August 2002)
% calculate the DIP statistic from the empirical pdf
[dip,xlow,xup, ifault, gcm, lcm, mn, mj]=hartigansdiptest(xpdf);
N=length(xpdf);
% calculate a bootstrap sample of size NBOOT of the dip statistic for a uniform pdf of sample size N (the same as empirical pdf)
boot_dip=[];
for i=1:nboot
unifpdfboot=sort(unifrnd(0,1,1,N));
% sim_data=poissrnd(d.random(lns,1));
%[c,l]=wavedec(sim_data(find(~isnan(sim_data))),15,'haar');
%[eas,ed_sim]=wenergy(c,l);
%sim_hist=ed_sim'/sum(ed_sim);
%xr=samp_dist(sh,100);
[unif_dip]=hartigansdiptest(unifpdfboot);
boot_dip=[boot_dip; unif_dip];
end;
boot_dip=sort(boot_dip);
p_value=sum(dip<boot_dip)/nboot;
% % Plot Boot-strap sample and the DIP statistic of the empirical pdf
% figure(1); clf;
% [hy,hx]=hist(boot_dip);
% bar(hx,hy,'k'); hold on;
% plot([dip dip],[0 max(hy)*1.1],'r:');