close all
clear all
disp('Goodness of Fit:  BetaGeometric Distribution')
disp('Pearson''s chi2 test')
 lw = 2.5; 
 set(0, 'DefaultAxesFontSize', 16);
 fs = 15;
 msize = 10;
%observed =[198 107 55 38 18 22 7 9 5 3 6 6 12]
% BetaGeometric Distribution 
betageom  = @(n, a, b) beta(a+1, b+n-1)/beta(a,b);

 probs=[];
for i=1:12
  probs=[probs betageom(i, 3.5, 5)]  ;
end
s=sum(probs);
probs=[probs 1-s];
n=486
expected = n*probs
observed =[198 107 55 38 18 22 7 9 5 3 6 6 12]
chi2 = sum((expected - observed).^2./expected)
pval = 1-chi2cdf(chi2, 13-1-2)

 
%

