Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
f8af5762
Commit
f8af5762
authored
Oct 18, 2018
by
Tiago Peixoto
Browse files
MixedMeasuredBlockState: Improve numerical stability
Use gammaln() in place of log(gamma()).
parent
aa39e4a6
Pipeline
#443
failed with stage
in 353 minutes and 58 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/inference/uncertain_blockmodel.py
View file @
f8af5762
...
...
@@ -593,19 +593,21 @@ class MixedMeasuredBlockState(UncertainBaseState):
def
sync_q
(
self
):
ra
,
rb
=
self
.
transform
(
self
.
n
.
fa
,
self
.
x
.
fa
)
self
.
q
.
fa
=
log
(
ra
)
-
log
(
rb
)
self
.
q
.
fa
=
ra
-
rb
dra
,
drb
=
self
.
transform
(
self
.
n_default
,
self
.
x_default
)
self
.
q_default
=
log
(
dra
)
-
log
(
drb
)
self
.
q_default
=
dra
-
drb
self
.
S_const
=
(
self
.
M
-
self
.
g
.
num_edges
())
*
log
(
drb
)
+
log
(
rb
)
.
sum
()
self
.
S_const
=
(
self
.
M
-
self
.
g
.
num_edges
())
*
drb
+
rb
.
sum
()
if
self
.
_state
is
not
None
:
self
.
_state
.
set_q_default
(
self
.
q_default
)
self
.
_state
.
set_S_const
(
self
.
S_const
)
def
transform
(
self
,
na
,
xa
):
ra
=
scipy
.
special
.
beta
(
na
-
xa
+
self
.
alpha
,
xa
+
self
.
beta
)
/
scipy
.
special
.
beta
(
self
.
alpha
,
self
.
beta
)
rb
=
scipy
.
special
.
beta
(
xa
+
self
.
mu
,
na
-
xa
+
self
.
nu
)
/
scipy
.
special
.
beta
(
self
.
mu
,
self
.
nu
)
ra
=
(
scipy
.
special
.
betaln
(
na
-
xa
+
self
.
alpha
,
xa
+
self
.
beta
)
-
scipy
.
special
.
betaln
(
self
.
alpha
,
self
.
beta
))
rb
=
(
scipy
.
special
.
betaln
(
xa
+
self
.
mu
,
na
-
xa
+
self
.
nu
)
-
scipy
.
special
.
betaln
(
self
.
mu
,
self
.
nu
))
return
ra
,
rb
def
set_hparams
(
self
,
alpha
,
beta
,
mu
,
nu
):
...
...
Write
Preview
Supports
Markdown
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