% Mardia, Kent and Bibby student scores data set
% The data set represents scores of 88 students 
% in (mechanics vectors algebra analysis statistics)
% For Handout 6
close all
clear all
set(0, 'DefaultAxesFontSize', 15);
fs = 14;
lw = 2;  
msize = 6;


scores = [ 77 82 67 67 81; 63 78 80 70 81; 75 73 71 66 81; 55 72 63 70 68; ...
           63 63 65 70 63; 53 61 72 64 73; 51 67 65 65 68; 59 70 68 63 56; ...
           62 60 58 62 70; 64 72 60 62 45; 52 64 60 63 54; 55 67 59 62 44; ...
           50 50 64 55 63; 65 63 58 56 37; 31 55 60 57 73; 60 64 56 54 40; ...
           44 69 53 53 53; 42 69 61 55 45; 62 46 61 57 45; 31 49 62 63 62; ...
           44 61 52 62 46; 49 41 61 49 64; 12 58 61 63 67; 49 53 49 62 47; ...
           54 49 56 47 53; 54 53 46 59 44; 44 56 55 61 36; 18 44 50 57 81; ... 
           46 52 65 50 35; 32 45 49 57 64; 30 69 50 52 45; 46 49 53 59 37; ...
           40 27 54 61 61; 31 42 48 54 68; 36 59 51 45 51; 56 40 56 54 35; ...
           46 56 57 49 32; 45 42 55 56 40; 42 60 54 49 33; 40 63 53 54 25; ...
           23 55 59 53 44; 48 48 49 51 37; 41 63 49 46 34; 46 52 53 41 40; ...
           46 61 46 38 41; 40 57 51 52 31; 49 49 45 48 39; 22 58 53 56 41; ...
           35 60 47 54 33; 48 56 49 42 32; 31 57 50 54 34; 17 53 57 43 51; ...
           49 57 47 39 26; 59 50 47 15 46; 37 56 49 28 45; 40 43 48 21 61; ...
           35 35 41 51 50; 38 44 54 47 24; 43 43 38 34 49; 39 46 46 32 43; ...
           62 44 36 22 42; 48 38 41 44 33; 34 42 50 47 29; 18 51 40 56 30; ...
           35 36 46 48 29; 59 53 37 22 19; 41 41 43 30 33; 31 52 37 27 40; ...
           17 51 52 35 31; 34 30 50 47 36; 46 40 47 29 17; 10 46 36 47 39; ...
           46 37 45 15 30; 30 34 43 46 18; 13 51 50 25 31; 49 50 38 23  9; ...
           18 32 31 45 40;  8 42 48 26 40; 23 38 36 48 15; 30 24 43 33 25; ...
            3  9 51 47 40;  7 51 43 17 22; 15 40 43 23 18; 15 38 39 28 17; ...
            5 30 44 36 18; 12 30 32 35 21;  5 26 15 20 20;  0 40 21  9 14];
%-------------------------------------------------------------------------- 

si=size(scores);
p = si(2);
n = si(1);

Sigma = 256*eye(p)+256*ones(p,p);

mu = 50*ones(p,1);
Pi = 4* eye(p)+ 4* ones(p,p);

mu_1 = inv (inv(Pi) + n * inv(Sigma)) * ( inv(Pi) * mu + n * inv(Sigma) * (mean(scores))' );
Pi1 = inv (inv(Pi) + n * inv(Sigma));

plot(mu,':')
hold on
plot(mu_1) 
plot(mu_1,'o')
plot(mean(scores),'r')
plot(mean(scores),'ro')
 xlabel('mechanics vectors algebra analysis statistics', 'fontweight' , 'bold')
print -depsc 'C:\Brani\Courses\Bayes\Handouts\Figs\bayes6_1fig.eps'
% BV, ISyE8843 9/1/04