LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
trace_idi.m
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
4%
5% [IDIk,J]=trace_idi(S,k,'aggregate',n) - computes IDI(k) using samples
6% of S=X1+...X_n
7%
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)
10%
11% see Sriram, Whitt, "Characterizing Superposition Arrival Processes...", JSAC 6, 1986
12IDIk=[];
13S=S(:);
14if nargin<2
15 [IDIk,support]=trace_idi(S,min([1000,ceil(length(S)/30)]));
16 return
17end
18for k=kset
19 if nargin<3
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
24 end
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
29 keff=floor(k/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
34 end
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)
39 Sk=[];
40 % find subsets that sum the closest possible to k
41 y=[];
42 for t0=1:(length(n)-ceil(sum(n)/k))
43 acc=0;
44 indexes=[1,0];
45 for t=t0:length(n)
46 acc=acc+n(t);
47 if acc > k
48 indexes(end,2)=t-1;
49 indexes(end+1,1:2)=[t,0];
50 y(end+1)=acc-n(t);
51 acc=n(t);
52 end
53 end
54 indexes(end,:)=[];
55 for i=1:size(indexes,1)
56 Sk(i)=sum(S(indexes(i,1):indexes(i,2)));
57 end
58 end
59 IDIk(end+1)=k*var(Sk)/mean(Sk)^2;
60 end
61end
62end