Major update on CCREClass and some bug fixes in the CRE class.

CCRE class is now "more logical" from a programing point of view.
Created a fucntion to create the bin-edges for the reference function.
"condensed" the calc function (removed redundancies)
This commit is contained in:
2022-03-27 17:12:16 +02:00
parent ce95974c7b
commit e68267182d
3 changed files with 64 additions and 36 deletions

View File

@ -6,30 +6,30 @@ A=randn(100);
%% create instance of CRE class
S1=CREClass;
%% Calculate by setting labda equal to each of the (unique) values in the data.
S1.UseHistProxy=false;
S1.UseHistProxyFlag=false;
S1.EqualSizeBinFlag=false;
S1.Data=A;% set gaussian data
S1.Calc;
% use histogram aproximation with unequal bin sizes in the histogram
disp(S1)
%% use histogram aproximation with unequal bin sizes in the histogram
S2=CREClass;
S2.UseHistProxy=true;
S2.UseHistProxyFlag=true;
S2.EqualSizeBinFlag=false;
S2.Data=A;% set gaussian data
S2.nBin=numel(A); % set nbin to npoints; This is fine as we use the cummulative distribution and the formulas as defined in Zografos
S2.Calc
% use histogram aproximation with equal bin sizes in the histogram
disp(S2)
%% use histogram aproximation with equal bin sizes in the histogram
S3=CREClass;
S3.UseHistProxy=true;
S3.UseHistProxyFlag=true;
S3.EqualSizeBinFlag=false;
S3.Data=A;% set gaussian data
S3.nBin=numel(A); % set nbin to npoints; This is fine as we use the cummulative distribution and the formulas as defined in Zografos
S3.Calc
%Check recalculation of edges
disp(S3)
%% Check recalculation of edges
S4=CREClass;
S4.UseHistProxy=true;
S4.UseHistProxyFlag=true;
S4.EqualSizeBinFlag=true;
S4.Data=A;% set gaussian data
S4.nBin=numel(A); % set nbin to npoints; This is fine as we use the cummulative distribution and the formulas as defined in Zografos
@ -40,16 +40,16 @@ S4.CalcEdges ; % force a recalculation of the edges
S4.Calc;
disp(S4)
return;
%% Show effect of scaling or ofsett the data
% Scale
S.Data=100*A;
S.UseHistProxy=true;
S.UseHistProxyFlag=true;
S.Calc;
disp(S);
% Offset
S.Data=A+10;
S.UseHistProxy=true;
S.UseHistProxyFlag=true;
S.Calc;
disp(S);
%%
@ -66,7 +66,7 @@ out(numel(w),1)=struct('w',[],'CRE',[],'CCRE',[],'R',[]);
for k=1:numel(w)
out(k).w=w(k);
CS=CCREClass;
CS.EquidistantBinFlag=false;
CS.EqualSizeBinFlag=false;
CS.Data=1*(1-abs(w(k)))*A+w(k)*B;
CS.nBin=50;
CS.DataRef=B;
@ -86,4 +86,4 @@ disp(CS);
plot([out(:).w],[out(:).CCRE],'o');
plot([out(:).w],[out(:).CRE],'x');
figure(3);clf
plot([out(:).w],[out(:).R],'d')
plot([out(:).w],[out(:).R],'d');