1function [IDIk,support]=trace_idi(S,kset,OPTION,n)
2% TRACE-IDI Computes the index of dispersion
for intervals of a trace
3% [IDIk,J]=trace_idi(S,k) - computes IDI(k)- J
is the number of points used
5% [IDIk,J]=trace_idi(S,k,
'aggregate',n) - computes IDI(k)
using samples
8% [IDIk,J]=trace_idi(S,k,
'aggregate-mix',n) - computes IDI(k)
using samples
9% of S_t=X1+...X_n(t), i.e., the cardinality of the t-th sum sample
is n(t)
11% see Sriram, Whitt,
"Characterizing Superposition Arrival Processes...", JSAC 6, 1986
15 [IDIk,support]=trace_idi(S,min([1000,ceil(length(S)/30)]));
20 support=length(S)-k-1;
21 Sk=zeros(1,length(S)-k);
22 for t=1:(length(S)-k-1)
23 Sk(t)=sum(S(t:(t+k-1))); %
for all subsets of length k
25 IDIk(end+1)=k*var(Sk)/mean(Sk)^2;
26 elseif strcmpi(OPTION,
'aggregate')
27 % data
is already aggregated
28 % S
is a sample of S=X1+...X_n
30 Sk=zeros(1,length(S)-keff);
31 support=length(S)/(keff);
32 for t=1:(length(S)-keff-1)
33 Sk(t)=sum(S(t:(t+keff-1))); %
for all subsets of length k
35 IDIk(end+1)=k*var(Sk)/mean(Sk)^2;
36 elseif strcmpi(OPTION,
'aggregate-mix')
37 % data
is already aggregated
38 % S
is a sample of S=X1+...X_n(i)
40 % find subsets that sum the closest possible to k
42 for t0=1:(length(n)-ceil(sum(n)/k))
49 indexes(end+1,1:2)=[t,0];
55 for i=1:size(indexes,1)
56 Sk(i)=sum(S(indexes(i,1):indexes(i,2)));
59 IDIk(end+1)=k*var(Sk)/mean(Sk)^2;