

clear all
close all
 disp('1300 Errors')
 lw = 3; 
 set(0, 'DefaultAxesFontSize', 16);
 fs = 17;
 msize = 10;

data=[...
18	17.8	135.5	70.5 104	108
21	18.8	188	69	71	72
18  25.1    153 68  60  63
21	24.1	150	69	69	75
18	13.2	130	66	99	102
18	13.4	175	70.5	63	63
18	18.3	162	70.5	73	75
18	12.9	156	69.5	68	66
19	7.70	139.5	71	78	81
19	39.4	221.5	64.5	97	90
18	16.9	148	72	60	63
19  30.1    170 68  63  69
19	11.8	166	72	79	78
19	6.80	137	71.5	58	57
18  27.8   145.5 63.5 99 93
18  17.1   118.5 67  88  84
20  23.9   109  59  96  96
18  25.0    112  64  99  105
21  36.0     184  64  125  120
19  18.4   174 69.5  92 96
18  27.2 123.5 64.5 81 81 
18  19.9 115.5 66  81 81
18  31.9 127 61.5 82 81
19  14.6  172 74 100 96
18  27.6 219.5 71.5 111  111
19  23.0  189.5 72.5 117  108
19  17.4 190.5 71 92  90
18  26.8 128  65  87  90 ];


age = data(:,1);
bf =data(:,2);
wei = data(:,3);
hei = data(:,4);
monitor = data(:,5);
count = data(:,6);
adiffs = abs(monitor - count);
%plot( (5:40), 0*(5:40), 'r-', 'LineWidth',2)
figure(1)
plot(bf, adiffs, 'o','LineWidth',2,...
                       'MarkerEdgeColor','k',...
                       'MarkerFaceColor','g',...
                       'MarkerSize',10)
   hold on
  [bb,Ibeta,res,Ires,stats] =regress(adiffs, [ones(size(bf)) bf]) 
  plot( (5:40),  bb(1) + bb(2) .* (5:40), 'k-', 'LineWidth', 2)
  xlabel('BF'); ylabel('Abs(device count - hand count)')
  axis tight
  b = glmfit(bf, adiffs,'poisson','link','log');
 adifffit = glmval(b, (5:40),'log');
 plot( (5:40),  adifffit, 'r-', 'LineWidth', 2)
  
%%  
  figure(2)
 [fr x]=hist(adiffs ,9)
  bar(x-0.5, fr/27,0.4,'y')
  hold on
plot(-5:0.01:11,  normpdf(-5:0.01:11, 3.07, 2.43),'r','linewidth',3)
xlabel('Absolute error')
ylabel('Frequency')
 axis tight
 
 normcdf(0, 3.07, 2.43)
 