-
Notifications
You must be signed in to change notification settings - Fork 0
/
GibbsChainData.m
78 lines (70 loc) · 2.23 KB
/
GibbsChainData.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
classdef GibbsChainData
properties
% Input
A % Data Matrix
T % Total # of samples
Tstart=1; % Changes if error occurs to resume sampling
pms % Hyperparameters (current)
d % Number of communities
k % k-flip parameter
zTrue % Generated Z matrix (if available)
qTrue % Generated Q matrix (if available)
iters % iteration variables for loops
% iters(1) = samples
% iters(2) =
% iters(3) =
% Output
zSamples % Samples generated by gibbs
qSamples % Samples generated by gibbs
pmsSamples % Samples generated by gibbs
logPs % Log probability of samples
SuffStatAll % SuffStats
cpuTime
wallTime
end
methods
% Constructs
function obj = GibbsChainData(A,T,d,k,pms,Z,Q)
obj.A = A;
obj.d = d;
obj.k = k;
obj.pms = pms;
if nargin > 5
obj.zTrue = Z;
obj.qTrue = Q;
end
obj.T = T;
obj.logPs = nan(3,T);
obj.pmsSamples = cell(1,T);
obj.SuffStatAll = cell(1,T);
obj.zSamples = cell(1,T);
obj.qSamples = cell(1,T);
obj.cpuTime = zeros(1,T+1);
obj.wallTime = zeros(1,T);
end
% Sampler
%function obj = sample(obj)
%function obj = posteriorpredictive(...)
% Update functions
% Extending data structures to accomendate new samples
function obj = updateT(obj,newT)
oldT = obj.T;
if oldT<newT
obj.Tstart = oldT+1; % Setting index for first sample
obj.T = newT;
obj.logPs = [obj.logPs nan(3,newT-oldT)];
obj.pmsSamples{newT} = [];
obj.SuffStatAll{newT} = [];
obj.zSamples{newT} = [];
obj.qSamples{newT} = [];
obj.cpuTime(newT) = 0;
obj.wallTime(newT) = 0;
end
end
% Results
% function MAP plot
% function AUC
% Compare exact clusterings?
% ...
end
end