forked from lawrennd/gpsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemBasisSample.m
103 lines (90 loc) · 2.79 KB
/
demBasisSample.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
% DEMBASISSAMPLE Do a simple demo of a basis function.
% GPSIM
lengthScale = 1;
locationParams = [2 4 6];
numPoints = 100;
numFuncs = 3;
fontName = 'vera';
randn('seed', 1e6)
rand('seed', 1e6)
minLim = min(locationParams)-2*lengthScale;
maxLim = max(locationParams)+2*lengthScale;
colors = {'r', 'g', 'b'};
figure
hold on
basisFunctions = zeros(numPoints, length(locationParams));
t = linspace(minLim, maxLim, numPoints)';
for i = 1:length(locationParams)
tcentred = t - locationParams(i);
basisFunctions(:, i) = exp(-tcentred.*tcentred/((lengthScale^2)))/(sqrt(2*pi)*lengthScale);
a = plot(t, basisFunctions(:, i), colors{i});
set(a, 'linewidth', 2);
end
pos = get(gca, 'position');
origpos = pos;
%pos(3) = pos(3)/2;
pos(4) = pos(4)/2;
set(gca, 'position', pos);
%set(gca, 'fontname', fontName);
set(gca, 'fontsize', 20);
printPlot(['demBasisSample', num2str(0)], '../tex/diagrams/', '../html/')
decays = [0.01 0.1 1]
sensitivity = [1 1 1]
mrnaBasisFunctions = zeros(numPoints, length(decays), length(locationParams));
sigma2 = lengthScale*lengthScale;
for i = 1:length(decays)
figure
hold on
for j = 1:length(locationParams);
decays2=decays(i)*decays(i);
tcentred = t - locationParams(j);
mrnaBasisFunctions(:, i, j) = exp(...
(decays2*sigma2/4 - decays(i)*(t-locationParams(j))) ...
+lnDiffCumGaussian(2/sqrt(2)*repmat( ...
(decays(i)*sigma2 + locationParams(j))/lengthScale, ...
size(t, 1), size(t, 2)),...
-2/sqrt(2)*(t - decays(i)*sigma2 - locationParams(j))/lengthScale));
a = plot(t, mrnaBasisFunctions(:, i, j), colors{j});
set(a, 'linewidth', 2);
end
pos = get(gca, 'position');
origpos = pos;
%pos(3) = pos(3)/2;
pos(4) = pos(4)/2;
set(gca, 'position', pos);
%set(gca, 'fontname', fontName);
set(gca, 'fontsize', 20);
printPlot(['demBasisSample', num2str(0), '_', num2str(i)], '../tex/diagrams/', '../html/')
end
w = randn(length(locationParams), numFuncs);
for i=1:numFuncs
figure
f = basisFunctions*w(:, i);
a = plot(t, f, 'b');
set(a, 'linewidth', 2);
pos = get(gca, 'position');
origpos = pos;
pos(4) = pos(4)/2;
set(gca, 'position', pos);
disp(w(:, i))
set(a, 'linewidth', 2);
%set(gca, 'fontname', fontName);
set(gca, 'fontsize', 20);
printPlot(['demBasisSample', num2str(i)], '../tex/diagrams/', '../html/')
end
for i=1:length(decays)
for j=1:numFuncs
figure
f = squeeze(mrnaBasisFunctions(:, i, :))*w(:, j);
a = plot(t, f, 'b');
set(a, 'linewidth', 2);
pos = get(gca, 'position');
origpos = pos;
pos(4) = pos(4)/2;
set(gca, 'position', pos);
set(a, 'linewidth', 2);
%set(gca, 'fontname', fontName);
set(gca, 'fontsize', 20);
printPlot(['demBasisSample', num2str(j), '_', num2str(i)], '../tex/diagrams/', '../html/')
end
end