annotate rDiff/src/tests/calcl_nbin_pdf.m @ 2:233c30f91d66

updated python based GFF parsing module which will handle GTF/GFF/GFF3 file types
author vipints <vipin@cbio.mskcc.org>
date Tue, 08 Oct 2013 07:15:44 -0400
parents 0f80a5141704
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
1 function [RET]=calcl_nbin_pdf(VAL,R,P)
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
2 %uses formula used by matlab for compatability
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
3
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
4 RET=zeros(size(VAL,1),size(VAL,2));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
5 IDX=VAL==round(VAL);
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
6 %RET(IDX) = exp(gammaln(R+VAL(IDX))-gammaln(VAL(IDX)+1)-gammaln(R)+R*log(P)+VAL(IDX)*log1p(-P));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
7
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
8
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
9 nk = (gammaln(R + VAL(IDX)) - gammaln(VAL(IDX) + 1) - gammaln(R));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
10 RET(IDX) = nk + (R.*log(P)) + (VAL(IDX).*log(1 - P));
0f80a5141704 version 0.3 uploaded
vipints
parents:
diff changeset
11 RET(IDX) = exp(RET(IDX));