Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
graph-tool
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
43
Issues
43
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tiago Peixoto
graph-tool
Commits
dc6d19ff
Commit
dc6d19ff
authored
Feb 20, 2017
by
Tiago Peixoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
blockmodel: Fix parameter names of weight distributions and add support for Jeffreys prior
parent
477df9b8
Pipeline
#265
passed with stage
in 390 minutes and 12 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
11 deletions
+24
-11
src/graph/inference/graph_blockmodel.hh
src/graph/inference/graph_blockmodel.hh
+1
-1
src/graph/inference/graph_blockmodel_util.hh
src/graph/inference/graph_blockmodel_util.hh
+19
-4
src/graph_tool/inference/blockmodel.py
src/graph_tool/inference/blockmodel.py
+4
-6
No files found.
src/graph/inference/graph_blockmodel.hh
View file @
dc6d19ff
...
...
@@ -1089,7 +1089,7 @@ public:
wparams
[
2
],
wparams
[
3
]);
});
break
;
break
;
case
weight_type
::
DELTA_T
:
// waiting times
if
((
r
!=
nr
)
&&
_ignore_degrees
[
v
]
>
0
)
{
...
...
src/graph/inference/graph_blockmodel_util.hh
View file @
dc6d19ff
...
...
@@ -258,6 +258,8 @@ double positive_w_log_P(DT N, double x, double alpha, double beta)
{
if
(
N
==
0
)
return
0.
;
if
(
alpha
==
0
&&
beta
==
0
)
// Jeffreys
return
lgamma
(
N
)
-
N
*
log
(
x
);
return
lgamma
(
N
+
alpha
)
-
lgamma
(
alpha
)
+
alpha
*
log
(
beta
)
-
(
alpha
+
N
)
*
log
(
beta
+
x
);
}
...
...
@@ -269,9 +271,18 @@ double signed_w_log_P(DT N, double x, double v, double m0, double k0, double v0,
{
if
(
N
==
0
)
return
0.
;
if
(
v0
==
0
&&
k0
==
0
)
// Jeffreys
{
if
(
N
>
1
)
return
lgamma
(
N
/
2.
)
-
log
(
N
)
/
2
-
N
*
log
(
v
)
/
2
-
(
N
/
2.
)
*
log
(
M_PI
);
else
return
-
log
(
pow
(
x
-
m0
,
2
)
+
v0
)
/
2
;
}
auto
k_n
=
k0
+
N
;
auto
nu_n
=
nu0
+
N
;
auto
v_n
=
(
v0
*
nu0
+
v
+
((
N
*
k0
)
/
(
k0
+
N
))
*
pow
(
m0
-
x
/
N
,
2
.
))
/
nu_n
;
auto
v_n
=
(
v0
*
nu0
+
v
+
((
N
*
k0
)
/
(
k0
+
N
))
*
pow
(
m0
-
x
/
N
,
2
))
/
nu_n
;
return
lgamma
(
nu_n
/
2.
)
-
lgamma
(
nu0
/
2.
)
+
(
log
(
k0
)
-
log
(
k_n
))
/
2.
+
(
nu0
/
2.
)
*
log
(
nu0
*
v0
)
-
(
nu_n
/
2.
)
*
log
(
nu_n
*
v_n
)
-
(
N
/
2.
)
*
log
(
M_PI
);
...
...
@@ -283,6 +294,8 @@ double geometric_w_log_P(DT N, double x, double alpha, double beta)
{
if
(
N
==
0
)
return
0.
;
if
(
alpha
==
0
&&
beta
==
.5
)
// Jeffreys
return
lbeta
(
N
,
x
+
.5
);
return
lbeta
(
N
+
alpha
,
x
+
beta
)
-
lbeta
(
alpha
,
beta
);
}
...
...
@@ -297,12 +310,14 @@ double binomial_w_log_P(DT N, double x, size_t n, double alpha, double beta)
// discrete: Poisson
template
<
class
DT
>
double
poisson_w_log_P
(
DT
N
,
double
x
,
double
r
,
double
th
eta
)
double
poisson_w_log_P
(
DT
N
,
double
x
,
double
alpha
,
double
b
eta
)
{
if
(
N
==
0
)
return
0.
;
return
lgamma
(
x
+
r
)
-
lgamma
(
r
)
-
r
*
log
(
theta
)
-
(
x
+
r
)
*
log
(
N
+
1.
/
theta
);
if
(
alpha
==
.5
&&
beta
==
0
)
// Jeffreys
return
lgamma
(
x
+
.5
)
-
(
x
+
.5
)
*
log
(
N
)
-
lgamma
(
.5
);
return
lgamma
(
x
+
alpha
)
-
(
x
+
alpha
)
*
log
(
N
+
beta
)
-
lgamma
(
alpha
)
+
alpha
*
log
(
beta
);
}
// ===============
...
...
src/graph_tool/inference/blockmodel.py
View file @
dc6d19ff
...
...
@@ -448,9 +448,10 @@ class BlockState(object):
self
.
wparams
=
libcore
.
Vector_Vector_double
()
for
i
,
rt
in
enumerate
(
self
.
rec_types
):
ps
=
Vector_double
()
if
rt
==
libinference
.
rec_type
.
real_exponential
:
defaults
=
OrderedDict
([(
"r"
,
1
),
(
"theta"
,
self
.
recs
[
i
].
fa
.
mean
())])
if
rt
in
[
libinference
.
rec_type
.
real_exponential
,
libinference
.
rec_type
.
discrete_poisson
]:
defaults
=
OrderedDict
([(
"alpha"
,
1
),
(
"beta"
,
self
.
recs
[
i
].
fa
.
mean
())])
elif
rt
==
libinference
.
rec_type
.
real_normal
:
defaults
=
OrderedDict
([(
"m0"
,
self
.
recs
[
i
].
fa
.
mean
()),
(
"k0"
,
1
),
...
...
@@ -459,9 +460,6 @@ class BlockState(object):
elif
rt
==
libinference
.
rec_type
.
discrete_geometric
:
defaults
=
OrderedDict
([(
"alpha"
,
1
),
(
"beta"
,
1
)])
elif
rt
==
libinference
.
rec_type
.
discrete_poisson
:
defaults
=
OrderedDict
([(
"r"
,
1
),
(
"theta"
,
self
.
recs
[
i
].
fa
.
mean
())])
elif
rt
==
libinference
.
rec_type
.
discrete_binomial
:
defaults
=
OrderedDict
([(
"N"
,
self
.
recs
[
i
].
fa
.
max
()),
(
"alpha"
,
1
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment