-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fourier.m
More file actions
44 lines (38 loc) · 743 Bytes
/
test_fourier.m
File metadata and controls
44 lines (38 loc) · 743 Bytes
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
true = normal_density(0, 0.5);
true = uniform_density(-5, 5);
true = mixture_density([1 1], true, normal_density(5, 0.3));
true = mixture_density([1 1], true, normal_density(-5, 0.7));
data = sample(true, 101);
if 0
tic
kern = kernel_density;
kern = train(kern, data);
toc
tic; logProb(kern, data(1)); toc
else
clear kern
end
tic
obj = fourier_density;
if 0
figure(2)
axis([-1 2 0 2]);
plot(obj)
end
obj = train(obj, data);
toc
tic; logProb(obj, data(1)); toc
figure(1)
plot(data, 0.1*ones(size(data)), 'wo');
axis([-10 10 0 1]);
%axis([-5 5 0 1]);
%axis([-30 30 0 1]);
draw(obj, 'b');
if exist('kern')
draw(kern, 'r');
end
draw(true, 'g--');
%set(gca, 'Color', [0 0 0])
axis tight
r = -30:0.1:30;
sum(exp(logProb(obj,r)))*0.1