function res=exam3_1
%example 3.1
%8/30/2007 by Changxing Ma

x=[
%ID  #PN RG472  RG246 K5    U10  RG532  W1   RG173 Amy1B RZ276 RG146
1   5   2   1   1   1   1   1   1   2   2   2
2   7   1   1   1   1   1   1   1   2   2   2
3   10  1   1   1   1   1   2   2   2   2   2
4   12  1   1   2   2   2   2   2   2   2   2
5   13  1   1   0   0   0   1   0   0   2   1
6   20  2   2   2   2   2   2   2   2   2   2
7   22  2   2   1   0   1   1   1   2   2   2
8   25  1   1   2   2   2   2   2   2   2   2
9   27  1   1   2   0   2   2   2   2   2   2
10  31  1   2   2   2   2   2   2   2   2   2
11  34  2   0   0   0   0   0   0   2   2   2
12  35  2   2   2   0   2   2   2   2   2   2
13  39  1   2   2   0   2   2   2   2   2   2
14  41  1   1   2   0   2   2   2   2   2   2
15  47  2   2   2   0   2   2   2   2   2   2
16  55  1   1   1   1   1   1   1   1   1   1
17  57  2   2   0   2   2   2   2   2   2   2
18  62  2   2   2   0   2   2   2   2   2   2
19  67  2   1   1   1   1   1   2   2   2   2
20  69  2   2   2   2   2   2   2   2   2   2
21  74  2   2   2   2   2   2   2   2   2   2
22  78  1   1   0   2   0   2   2   2   2   2
23  82  2   2   2   2   2   2   2   2   2   2
24  84  1   1   2   2   2   2   2   2   2   2
25  87  1   1   0   1   1   1   1   2   2   2
26  88  1   1   2   2   2   2   2   2   2   2
27  89  2   2   2   2   2   1   2   2   2   2
28  90  1   2   2   2   2   2   1   1   1   1
29  94  1   1   1   0   1   2   2   2   2   2
30  97  2   2   2   0   0   2   2   2   1   2
31  100 0   0   0   0   2   2   0   2   2   2
32  105 2   2   2   2   2   2   2   2   2   2
33  106 1   1   1   1   1   2   2   2   2   2
34  107 2   2   2   0   2   2   2   2   2   2
35  110 1   1   1   0   2   2   2   2   2   2
36  116 1   2   1   1   1   1   1   1   1   1
37  124 0   0   0   1   1   1   0   2   2   2
38  130 1   1   2   2   2   2   2   2   2   2
39  144 1   1   2   1   2   1   1   1   1   1
40  146 0   2   0   1   1   0   2   1   1   1
41  147 1   2   2   2   2   2   2   1   1   1
42  163 0   0   0   0   2   2   0   2   2   2
43  169 2   2   2   2   2   2   2   2   2   2
44  171 2   2   0   1   2   0   1   2   2   2
45  180 2   2   2   2   2   2   2   2   2   2
46  183 0   2   2   0   2   2   2   2   2   2
47  184 0   2   2   2   2   2   2   2   2   2
48  188 1   1   0   1   1   1   1   1   1   1
49  192 0   2   2   0   0   2   2   2   2   0
50  196 2   2   0   1   0   0   0   2   2   2
51  200 1   2   2   2   2   2   2   2   2   2
52  210 1   1   1   1   1   1   2   2   2   2
53  226 2   2   2   2   2   2   2   2   2   2
54  228 1   1   1   1   1   1   0   2   2   2
55  232 1   1   1   1   1   1   1   2   2   2
56  236 2   2   2   0   2   2   2   2   2   2
57  238 2   2   2   2   2   2   2   2   2   2
58  240 2   2   2   2   2   2   2   2   2   2
59  241 2   2   2   0   2   2   2   2   2   2
60  251 1   1   1   1   1   2   2   2   2   2
61  252 2   2   2   2   2   2   2   1   1   1
62  253 0   0   0   0   1   1   0   1   1   0
63  262 0   1   0   2   0   2   2   2   1   2
64  268 2   2   2   2   2   2   2   1   1   1
65  269 1   2   2   2   2   2   2   2   2   2
66  272 1   2   2   2   2   2   2   2   2   2
67  281 1   2   2   2   2   2   2   2   2   2
68  284 1   1   1   1   1   1   2   2   2   2
69  288 2   2   2   2   2   2   2   2   2   2
70  290 1   1   1   1   1   2   2   2   2   2
71  291 1   1   1   2   1   2   2   2   2   2
72  295 1   1   1   2   1   2   2   2   2   2
73  303 1   1   1   1   1   1   1   1   1   1
74  313 2   2   2   2   2   2   2   2   2   2
75  326 2   2   2   2   2   2   2   2   2   2
76  329 2   1   1   1   1   1   1   1   1   1
77  332 2   2   2   2   2   2   2   2   2   2
78  333 1   1   1   1   1   1   2   2   2   2
79  335 2   2   2   0   2   2   2   2   2   2
80  336 1   1   1   1   1   1   1   2   2   2
81  350 2   2   2   2   2   2   2   2   2   2
82  351 1   1   1   1   1   2   2   2   2   2
83  355 2   2   2   2   0   0   2   2   2   2
84  356 2   2   2   2   2   2   2   2   2   2
85  359 1   1   1   1   1   2   2   2   2   2
86  361 1   1   1   0   2   2   2   2   2   2
87  372 2   2   2   2   2   2   2   2   2   2
88  374 0   2   2   0   0   2   0   0   0   0
89  387 1   2   2   0   2   2   2   2   2   0
90  388 1   1   1   0   1   1   1   1   1   1
91  389 1   1   1   0   1   2   2   2   2   0
92  391 2   2   2   0   2   2   2   2   2   0
93  397 1   1   1   1   1   1   2   2   2   0
94  398 1   1   0   0   0   1   0   2   1   0
95  403 1   1   1   1   1   1   1   2   2   2
96  412 2   1   2   0   2   2   2   2   2   2
97  417 2   2   2   2   2   2   2   2   2   0
98  424 1   2   2   2   2   2   2   2   2   2
99  429 2   1   1   1   1   1   2   2   1   2
100 435 2   2   2   2   2   2   2   2   2   2
101 436 1   1   1   2   1   2   2   2   2   2
102 438 0   0   1   0   1   1   0   1   1   1
103 440 2   2   2   2   2   1   2   2   2   2
104 442 2   1   2   2   2   2   2   2   2   2
105 455 2   2   0   2   2   2   0   2   1   1
106 463 2   2   2   2   2   2   2   2   2   2
107 467 1   1   2   2   2   2   2   2   2   2
108 475 1   1   1   1   1   2   2   2   2   2
109 476 2   2   2   2   2   2   2   2   2   2
110 478 2   2   1   1   1   1   2   2   2   2
111 489 2   2   2   2   2   2   2   2   2   2
112 550 1   1   1   1   1   2   2   2   2   2
113 556 2   2   2   2   2   2   2   2   2   2
114 558 1   1   2   0   2   2   2   2   2   2
115 631 1   2   2   2   2   2   2   2   2   2
116 790 2   1   1   1   1   1   2   2   2   2
117 936 2   2   2   0   2   2   2   2   0   2
118 1505 1   1   1   1   1   1   2   2   2  1
119 1508 0   0   1   1   1   1   0   2   2  2
120 1542 1   1   1   1   1   1   1   2   2  2
121 1544 1   1   1   1   1   2   2   2   2  1
122 1564 0   2   2   0   2   0   2   2   2  2
123 1566 1   1   1   1   1   1   1   2   2  1];
res=[];
mrkname=['RG472'
   'RG246' 
   'K5   ' 
   'U10  '
   'RG532'  
   'W1   '
   'RG173' 
   'Amy1B' 
   'RZ276' 
   'RG146'];
%%%example 3.1
for i=1:10
   N1=length(find(x(:,i+2)==2)); N2=length(find(x(:,i+2)==1));
   LR=2*(N1*log(N1/(N1+N2))+N2*log(N2/(N1+N2))-N1*log(1/2)-N2*log(1/2));
   pLR=chi2pdf(LR,1);
   N=[N1 N2]; EN=sum(N)*[1/2 1/2];
   chi=sum((N-EN).^2./EN);
   pchi=chi2pdf(chi,1);
   res=[res sprintf([mrkname(i,:) '  ' num2str(N1) ' ' num2str(N2) ' ']) sprintf('%8.3f %8.3f %8.3f %8.3f',[chi pchi LR pLR]')  sprintf('\n')];
end

