Problem: Given a six-sided die, fitted with accelerometers, we want to estimate which side is up by just looking at the accelerometer data.
Solution: We model each side by a multivariate Gaussian, and perform Maximum Likelihood (ML) estimation.
Concrete: Within the die, two dual-axis accelerometers are fitted, so we'll have 4 values, two of which should behave approximately the same. See the cubicles website for more information. The input vectors, Gaussians, and mean vectors are therefore four-dimensional.
[1: Gaussian Modelling] [2: Maximum Likelihood Estimation] [3: generating the PICC-code] [4: visualization] [5: adding gestures]
We start by reducing the dimension of the datasets, since we can only visualize the Gaussians of two-dimensional data. We used FastICA (developed at Helsinki University of Technology) to go from four signals to two:
>> fasticag;

..these are the four input signals (from the four accelerometers) .. and the result we get is:

We can then extract the samples from the six sides in different sub-datasets:
>> side1 = cubicle1(1:150,:);
>> side2 = cubicle1(200:350,:);
>> side3 = cubicle1(423:573,:);
>> side4 = cubicle1(612:762,:);
>> side5 = cubicle1(810:940,:);
>> side6 = cubicle1(1000:1150,:);
And calculate the means and covariances for the Gaussians for each dataset:
>> mean1 = mean(side1);
>> mean2 = mean(side2);
>> mean3 = mean(side3);
>> mean4 = mean(side4);
>> mean5 = mean(side5);
>> mean6 = mean(side6);
>> cov1 = cov(side1);
>> cov2 = cov(side2);
>> cov3 = cov(side3);
>> cov4 = cov(side4);
>> cov5 = cov(side5);
>> cov6 = cov(side6);
Which gives:
>> disp(mean1); disp(mean2); disp(mean3); disp(mean4);disp(mean5);
disp(mean6);
1.8042 23.7048
3.3642 25.1030
3.3234 22.7220
0.9986 23.1180
1.0428 25.4809
2.5539 24.5091
>> disp(cov1); disp(cov2); disp(cov3); disp(cov4);disp(cov5); disp(cov6);
1.0e-003 *
0.2795 0.0935
0.0935 0.2149
1.0e-003 *
0.3495 0.0916
0.0916 0.2268
1.0e-003 *
0.4180 0.2374
0.2374 0.3632
1.0e-003 *
0.2973 0.0811
0.0811 0.2036
1.0e-003 *
0.8443 -0.1195
-0.1195 0.2682
1.0e-003 *
0.2187 0.0772
0.0772 0.2216
These variables are then used to calculate each Gaussian, and take the maximum of the six possibilities to plot a surface graph:
for x1=0:0.01:4,
for x2=22:0.01:26,
G1 =
1/((2*pi)^0.5*det(cov1))*exp(-0.5*([x1 x2] - mean1)*(inv(cov1))*([x1 x2] -
mean1)');
G2 =
1/((2*pi)^0.5*det(cov2))*exp(-0.5*([x1 x2] - mean2)*(inv(cov2))*([x1 x2] -
mean2)');
G3 =
1/((2*pi)^0.5*det(cov3))*exp(-0.5*([x1 x2] - mean3)*(inv(cov3))*([x1 x2] -
mean3)');
G4 =
1/((2*pi)^0.5*det(cov4))*exp(-0.5*([x1 x2] - mean4)*(inv(cov4))*([x1 x2] -
mean4)');
G5 =
1/((2*pi)^0.5*det(cov5))*exp(-0.5*([x1 x2] - mean5)*(inv(cov5))*([x1 x2] -
mean5)');
G6 =
1/((2*pi)^0.5*det(cov6))*exp(-0.5*([x1 x2] - mean6)*(inv(cov6))*([x1 x2] -
mean6)');
mrt(((x1)*100)+1, ((x2-22)*100)+1) =
max([G1 G2 G3 G4 G5 G6]);
end
end
>> surfl(mrt);
>> colormap gray;

You can clearly see the six Gaussians per side, and also note the nice distribution across the two-dimensional input space.
We can now add a trace-plot on top of the surface plot that just connects the data points in the ICA-ed dataset:
>> hold
Current plot held
>> plot3((cubicle1(:,1)-22).*100+1, cubicle1(:,2).*100+1,
ones(length(cubicle1(:,1)),1) );

Document created by Kristof Van Laerhoven, March 2003.