-
Notifications
You must be signed in to change notification settings - Fork 0
/
decor3.m
73 lines (54 loc) · 1.45 KB
/
decor3.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
clc
close all
clear all
%% Reduction de 3 a deux composantes
decor2
t_set = [t_P300; t_NP300];
%% Averages
avg_P300 = sum(t_P300) ./ size(t_P300, 1);
avg_NP300 = sum(t_NP300) ./ size(t_NP300, 1);
avg_set = sum(t_set) ./ size(t_set, 1);
%% Covariance
cov_set = cov(t_set)
%% Eigenvalues and vectors
[eig_vectors, eig_values] = eig(cov_set)
%% Dimension reduction
% Choosing the dimensions with the highest variance
max_values_index = 2
tt = tt * eig_vectors(max_values_index, :)'
unit_vectors = eig_vectors(max_values_index, :)'
%% Transforming data
t_P300 = (t_P300) * unit_vectors;
t_NP300 = (t_NP300) * unit_vectors;
t_P300 = -t_P300;
t_NP300 = -t_NP300;
offset = min([min(t_P300(:)), min(t_NP300(:))]) - 0.1;
t_P300 = t_P300 - offset;
t_NP300 = t_NP300 - offset;
figure()
hold on
grid('on')
title('Decorrelation 3 composantes')
scatter(t_P300(:,1), zeros(size(t_P300)), 'filled')
scatter(t_NP300(:,1), zeros(size(t_NP300)), 'filled')
hold off
%% Histograms - P300 And NP300
% T3D1
figure()
nbins = 30;
h = histfit(t_P300(:,1),nbins, 'lognormal');
h(1).FaceAlpha = 0.5;
hold on
h = histfit(t_NP300(:,1),nbins, 'normal');
h(1).FaceAlpha = 0.5;
legend('P300','' ,'NP300', '')
title('T3D1 Parameter Histogram')
hold off
%% Frontier
pd_P300 = fitdist(t_P300(:,1),'lognormal')
pd_NP300 = fitdist(t_NP300(:,1),'normal')
x = linspace(0, 1.5, 1000);
pdf_p = pd_P300.pdf(x);
pdf_np = pd_NP300.pdf(x);
[~, frontier_i] = min(abs(pdf_np./pdf_p -1));
front = x(frontier_i)