CRE_RB_and_CCRE/TestCREClass.m

59 lines
1.2 KiB
Mathematica
Raw Normal View History

2020-02-25 17:30:53 +01:00
%% Test CCRE and CRE class
% show some default behaviour
% and test the error handling.
%% set some constants
A=randn(100);
%% create instance of CRE class
2019-04-04 08:35:34 +02:00
S=CREClass;
2020-02-25 17:30:53 +01:00
%% check histogram vs "new" technique
% NB I come to the conclusion that the new method is not always working.
% Why?
S.Data=A;% set gaussian data
S.nBin=(numel(S.Data)); % set nbin to npoints; This is fine as we use the cummulative distribution and the formulas as defined in Zografos
% use histogram
2019-04-04 08:35:34 +02:00
S.UseHistProxy=true;
S.Calc;
S
2020-02-25 17:30:53 +01:00
% Use my aproximation for the histogram
% only do this if the number of data points is not too big.
2019-04-04 08:35:34 +02:00
S.UseHistProxy=false;
S.Calc;
S
2020-02-25 17:30:53 +01:00
%% Show effect of scaling or ofsett the data
% Scale
S.Data=100*A;
2019-04-04 08:35:34 +02:00
S.UseHistProxy=true;
2020-02-20 18:14:55 +01:00
S.Calc;
2019-04-04 08:35:34 +02:00
S
2020-02-25 17:30:53 +01:00
% Offset
S.Data=A+10;
S.UseHistProxy=true;
2020-02-20 18:14:55 +01:00
S.Calc;
S
2020-02-25 17:30:53 +01:00
%%
2020-02-20 18:14:55 +01:00
%% Test CCRE class
2020-02-21 08:42:07 +01:00
figure(1);clf;hold on
figure(2);clf;
figure(3);clf;hold on;
A=randn(100);
B=A;
B(:)=A(randperm(numel(A)))
2020-02-21 08:42:07 +01:00
for k=-1:0.1:1
CS=CCREClass;
CS.Data=1*(1-abs(k))*A+k*B;
CS.nBin=50;
2020-02-21 08:42:07 +01:00
CS.DataRef=B;
CS.nBinRef=500;
2020-02-21 08:42:07 +01:00
CS.Calc;
figure(1);
2020-02-21 08:42:07 +01:00
plot(k,CS.CCRE,'o')
plot(k,CS.CRE,'x');
figure(2);
scatter(CS.DataRef(:),CS.Data(:));
figure(3);
plot(k,CS.CCRE./CS.CRE,'d');
end
2020-02-25 17:30:53 +01:00
CS
snapnow