view rDiff/src/variance/predict_variance.m @ 3:29a698dc5c7e default tip

Merge multiple heads.
author Dave Bouvier <dave@bx.psu.edu>
date Mon, 27 Jan 2014 14:15:36 -0500
parents 0f80a5141704
children
line wrap: on
line source

function [VARIANCE]=predict_variance(MEANS,VARIANCE_FCT)
%predict the variances for the means
if isstruct(VARIANCE_FCT)
    %use the estimated variance function
    VARIANCE=exp(predict(VARIANCE_FCT,log(full(MEANS))));
else
    %use parmeters a,b,c to compute the variance function
    a=VARIANCE_FCT(1);
    b=VARIANCE_FCT(2);
    c=VARIANCE_FCT(3);
    VARIANCE=a+MEANS*b+(MEANS.^2)*c;
end

%Make sure the variance is bigger than the poisson
%variance. Otherwise the NB cannot be definied

VARIANCE=max([VARIANCE,MEANS*(1e-8)],[],2);

return