Updated hist command to histcount in order to comply with matlab development
This commit is contained in:
parent
fb282e53e1
commit
2c7a9f90f0
16
CREClass.m
16
CREClass.m
|
@ -76,11 +76,13 @@ classdef CREClass < handle
|
|||
if isempty(obj.nBin)
|
||||
obj.nBin=floor(numel(obj.Data)./10);
|
||||
end
|
||||
[N,bin]=hist(obj.Data(:),obj.nBin);
|
||||
N=transpose(N);
|
||||
P=N./sum(N);
|
||||
CP=cumsum(P);
|
||||
FC=1-CP;
|
||||
%update part below to prefered matlab commands
|
||||
% [N,bin]=hist(obj.Data(:),obj.nBin);
|
||||
% N=transpose(N);
|
||||
% P=N./sum(N);
|
||||
% CP=cumsum(P);
|
||||
[CP,bin]=histcounts(obj.Data(:),obj.nBin,'Normalization','cdf');
|
||||
FC=1-transpose(CP);
|
||||
FC(FC<0)=0;
|
||||
dl=ones(size(FC))./numel(FC);
|
||||
else
|
||||
|
@ -90,7 +92,7 @@ classdef CREClass < handle
|
|||
for k=1:numel(q)
|
||||
FC(k)=sum(obj.Data(:)>=q(k));
|
||||
if k==1
|
||||
dl(k)=(q(k+1)-q(k))/2; %should I divide by 2?
|
||||
dl(k)=(q(k+1)-q(k))/2;
|
||||
elseif k==numel(q)
|
||||
dl(k)=(q(k)-q(k-1))/2;
|
||||
else
|
||||
|
@ -101,7 +103,7 @@ classdef CREClass < handle
|
|||
end
|
||||
LogFC=log(FC);
|
||||
LogFC(~isfinite(LogFC))=0;%the log of 0 is -inf. however in Fc.*logFc it should end up as 0. to avoid conflicts removing the -inf
|
||||
if any(isnan(FC));keyboard;end
|
||||
if any(isnan(FC));error('something went wrong');end %catch a posible error.
|
||||
obj.CRE=-transpose(dl)*(FC.*LogFC)./(transpose(dl)*FC); %CRE zografos
|
||||
%% get the RB
|
||||
dl(FC>0.5)=0; %set the weight for all in the histogram to the left side (i.e. <p50) to 0
|
||||
|
|
Loading…
Reference in New Issue