Mercurial > repos > vipints > rdiff
comparison rDiff/src/variance/plot_variance_fit.m @ 0:0f80a5141704
version 0.3 uploaded
author | vipints |
---|---|
date | Thu, 14 Feb 2013 23:38:36 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:0f80a5141704 |
---|---|
1 function []=plot_variance_fit(VARIANCE,MEANS,VARS,MAX_X,MAX_Y) | |
2 | |
3 if nargin<=3 | |
4 MAX_X=1000; | |
5 MAX_Y=1000; | |
6 end | |
7 | |
8 %values for which to plot the variance function | |
9 pp=0.1:1:MAX_X; | |
10 | |
11 %Define the legend entries | |
12 LEG={}; | |
13 FIG_HANDLES=[]; | |
14 figure; | |
15 if and(not(isempty(MEANS)),not(isempty(VARS))) | |
16 LEG{end+1}='Observation'; | |
17 FIG_HANDLES(end+1)=plot(MEANS,VARS,'.'); | |
18 end | |
19 hold on | |
20 %plot the predicted variances | |
21 FIG_HANDLES(end+1)=plot(pp',predict_variance(pp',VARIANCE),'r'); | |
22 LEG{end+1}='Variance fit'; | |
23 | |
24 plot(pp,pp,'g') | |
25 | |
26 %Plot sliding window | |
27 RR=zeros(1,MAX_X); | |
28 for i=1:MAX_X | |
29 TIDX=and(MEANS>i,MEANS<i*1.1+1); | |
30 RR(i)= mean(VARS(TIDX)); | |
31 end | |
32 FIG_HANDLES(end+1)=plot(1:MAX_X,RR,'k'); | |
33 LEG{end+1}='Sliding window'; | |
34 | |
35 %Plot poisson | |
36 FIG_HANDLES(end+1)=plot(pp,pp,'g'); | |
37 LEG{end+1}='Poisson variance'; | |
38 | |
39 legend(FIG_HANDLES,LEG) | |
40 xlabel('mean') | |
41 ylabel('variance') | |
42 | |
43 % Change window | |
44 xlim([0,MAX_X]) | |
45 ylim([0,MAX_Y]) | |
46 | |
47 return |