0
|
1 function [VARIANCE]=predict_variance(MEANS,VARIANCE_FCT)
|
|
2 %predict the variances for the means
|
|
3 if isstruct(VARIANCE_FCT)
|
|
4 %use the estimated variance function
|
|
5 VARIANCE=exp(predict(VARIANCE_FCT,log(full(MEANS))));
|
|
6 else
|
|
7 %use parmeters a,b,c to compute the variance function
|
|
8 a=VARIANCE_FCT(1);
|
|
9 b=VARIANCE_FCT(2);
|
|
10 c=VARIANCE_FCT(3);
|
|
11 VARIANCE=a+MEANS*b+(MEANS.^2)*c;
|
|
12 end
|
|
13
|
|
14 %Make sure the variance is bigger than the poisson
|
|
15 %variance. Otherwise the NB cannot be definied
|
|
16
|
|
17 VARIANCE=max([VARIANCE,MEANS*(1e-8)],[],2);
|
|
18
|
|
19 return
|