diff rDiff/src/variance/predict_variance.m @ 0:0f80a5141704

version 0.3 uploaded
author vipints
date Thu, 14 Feb 2013 23:38:36 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/rDiff/src/variance/predict_variance.m	Thu Feb 14 23:38:36 2013 -0500
@@ -0,0 +1,19 @@
+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