From baac9e2032632a2542031bfb170bea04abc36aa0 Mon Sep 17 00:00:00 2001 From: Renken Date: Thu, 20 Feb 2020 18:14:55 +0100 Subject: [PATCH] Added the first attempt at CCRE --- CREClass.m | 8 +++++++- TestCREClass.m | 14 ++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/CREClass.m b/CREClass.m index 1611f1c..22c4c46 100644 --- a/CREClass.m +++ b/CREClass.m @@ -104,7 +104,13 @@ classdef CREClass < handle 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));error('something went wrong');end %catch a posible error. - obj.CRE=-transpose(dl)*(FC.*LogFC)./(transpose(dl)*FC); %CRE zografos + if transpose(dl)*FC==0; + %if only one value in the most left bin in the distribution I may get a 0 divided by 0 + %as the CRE of a delta function is 0, enforce this outcome + obj.CRE=0; + else + obj.CRE=-transpose(dl)*(FC.*LogFC)./(transpose(dl)*FC); %CRE zografos + end %% get the RB dl(FC>0.5)=0; %set the weight for all in the histogram to the left side (i.e.