-
Notifications
You must be signed in to change notification settings - Fork 11
/
entropyFunction.m
58 lines (49 loc) · 1.88 KB
/
entropyFunction.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function [E] = entropyFunction(classifiedData,lagVect,nBinMat,NoDataCode,parallelWorkers)
[nData,nSignals] = size(classifiedData);
[nLags,~] = size(lagVect); %nLags includes the zero lag which is first
lagRange = [min(lagVect) max(lagVect)]; % 0 must be included somewhere in lagVect
nYw = 1; % the number of data points signifiying the previous history of Y. Hard-coded as 1 point previous for now, but code structured to make this an option in the future
nTuples = nData+lagRange(1)-max([lagRange(2) nYw])-1;
% INITIALIZE PARALLEL OUTPUTS OF THE SHANNON BIT FUNCTION
HXt = NaN(nSignals,nSignals,nLags);
HYw = NaN(nSignals,nSignals,nLags);
HYf = NaN(nSignals,nSignals,nLags);
HXtYw = NaN(nSignals,nSignals,nLags);
HXtYf = NaN(nSignals,nSignals,nLags);
HYwYf = NaN(nSignals,nSignals,nLags);
HXtYwYf = NaN(nSignals,nSignals,nLags);
I = NaN(nSignals,nSignals,nLags);
T = NaN(nSignals,nSignals,nLags);
nCounts = NaN(nSignals,nSignals,nLags);
% PARALLELIZE ON MULTIPLE TIME LAGS
parfor (i = 1:nLags,parallelWorkers)
[ HXt(:,:,i), ...
HYw(:,:,i), ...
HYf(:,:,i), ...
HXtYw(:,:,i), ...
HXtYf(:,:,i), ...
HYwYf(:,:,i), ...
HXtYwYf(:,:,i), ...
I(:,:,i), ...
T(:,:,i), ...
nCounts(:,:,i) ] ...
= ShannonBitsWrapper...
(classifiedData, ...
lagVect(i), ...
nTuples, ...
nBinMat, ...
lagRange,...
nYw, ...
NoDataCode);
end
% ASSIGN ALL OUTPUT VARIABLES TO THE TRANSFER STRUCTURE "E"
E.HXt=HXt;
E.HYw=HYw;
E.HYf=HYf;
E.HXtYw=HXtYw;
E.HXtYf=HXtYf;
E.HYwYf=HYwYf;
E.HXtYwYf=HXtYwYf;
E.I=I;
E.T=T;
E.nCounts=nCounts;