
close all
clear all


 disp('NOT AT ALL LIKE ME')
 lw = 2.5; 
 set(0, 'DefaultAxesFontSize', 16);
 fs = 15;
 msize = 10;





%You  have a theory that if you ask subjects to sort one-sentence
%characteristics of people (e.g. "I eat too fast") into five piles ranging from
%{\it not at all like me}  to  {\it very much like me,} the percentage
%placed in each of five piles will be approximately 10, 20, 40, 20, and 10.
%You have one of your friends sort 50 statements, and you obtain the
%following data: 8, 9, 21, 8, and 4.

%Do these data support your hypothesis at $\alpha = 5\%.$?





 ni=[8 9 21 8 4];
 n= sum(ni)
 %n = 50
 theopi = [10 20 40 20 10]/100
% theopi = 0.1000    0.2000    0.4000    0.2000    0.1000

 npi=50*theopi
% npi = 5    10    20    10     5

ch2 = sum((ni - npi).^2 ./npi)
%ch2 = 2.5500

 pval = 1 - chi2cdf(2.55, 5-1)
% pval = 0.6357

 crit= chi2inv(1-0.05, 5-1)
% crit = 9.4877
