-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtest.m
36 lines (30 loc) · 1.17 KB
/
test.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
% Test script for the Matlab package SNetOC
clear
close all
fprintf('=======================================\n')
fprintf(' TEST Matlab Package SNetOC \n')
fprintf('=======================================\n')
% Add path
addpath ./GGP/ ./CGGP/ ./utils/
% Sample CGGP graph
p = 2; % nb of communities
alpha = 20; sigma = .5; tau = 1;
Fdist.name = 'gamma';
Fdist.param.a = .2;
Fdist.param.b = 1/p;
gamma = zeros(p,1);
obj = graphmodel('CGGP', p, alpha, sigma, tau, Fdist, gamma);
G = graphrnd(obj, 1e-6);
plot_degree(G, 'or', 2);
% MCMC sampler for CGGP graph
hyper_alpha = [0.01,0.01]; hyper_sigma = [0.01, 0.01]; hyper_tau = [0.01,0.01];
hyper_Fdist.name = 'gamma';
hyper_Fdist.param.a = [0.01, 0.01];
hyper_Fdist.param.b = [0.01, 0.01];
objprior = graphmodel('CGGP', p, hyper_alpha, hyper_sigma, hyper_tau, hyper_Fdist, gamma);
niter = 100; nburn = 50; nadapt = niter/4; thin = 2; nchains = 1; verbose = true;
objmcmc = graphmcmc(objprior, niter, nburn, thin, nchains, nadapt);
objmcmc = graphmcmcsamples(objmcmc, G, verbose);
fprintf('=======================================\n')
fprintf(' TEST COMPLETED \n')
fprintf('=======================================\n')