Advanced Statistics With Matlab
Advanced Statistics With Matlab
Tutorial 5♣ :
Advanced Statistics with MATLAB
Daniela Raicu
[email protected]
School of Computer Science, Telecommunications, and Information
Systems
DePaul University, Chicago, IL 60604
X =
1 1 2 3
7 8 9 7
1 3 2 1
10 9 11 9
2 2 1 1
3 4 1 2
» cov(X)
ans =
♣
Event Sponsor: Visual Computing Area Curriculum Quality of Instruction Council (QIC) grant
Tutorial 5: Advanced Statistics with Matlab Page 2 of 5 04/22/2004
» cov(X(:,1))
ans =
13.6000
» cov(X(:,2))
ans =
10.7000
» eig(cov(X))
ans =
0.5731
0.1590
1.4018 %second largest eigenvalue that captures the second largest variance
53.3994 %largest eigenvalue that captures the largest variance in the data
pc =
score =
latent =
Tutorial 5: Advanced Statistics with Matlab Page 3 of 5 04/22/2004
53.3994
1.4018
0.5731
0.1590
tsquare =
4.1571
2.2893
3.0077
3.2088
3.2088
4.1284
3. Canonical Correlation
Canonical correlation analysis for two types of attributes: “Canoncorr.m”
U = (X - repmat(mean(X),N,1))*A and
V = (Y - repmat(mean(Y),N,1))*B.
Example:
load carbig;
X = [Displacement Horsepower Weight Acceleration MPG];
nans = sum(isnan(X),2) > 0;
[A B r U V] = canoncorr(X(~nans,1:3), X(~nans,4:5));
plot(U(:,1),V(:,1),'.');
xlabel('0.0025*Disp + 0.020*HP - 0.000025*Wgt');
ylabel('-0.17*Accel + -0.092*MPG')
>> A
A =
0.0025 0.0048
0.0202 0.0409
-0.0000 -0.0027
>> size(X)
ans =
Tutorial 5: Advanced Statistics with Matlab Page 4 of 5 04/22/2004
406 5
>> B
B =
-0.1666 -0.3637
-0.0916 0.1078
>> r
r =
0.8782 0.6328
4. Polynomial fitting
>> Y =
1 1
7 8
1 3
10 9
2 2
3 4
2 3
Tutorial 5: Advanced Statistics with Matlab Page 5 of 5 04/22/2004
6 6
» plot(Y(:,2),Y(:,1),'+')
>> Y_new=polyval(P,Y(:,1))
Y_new =
1.7697
7.2612
1.7697
9.1731
2.8394
3.8473
2.8394
6.5004
>> plot(Y(:,2),Y(:,1),'*',Y_new(:,1),Y(:,1),'+')