igraph / xdata-igraph

xdata igraph, has been merged into igraph/igraph
GNU General Public License v2.0
18 stars 3 forks source link

hsbm.game with arbitrary sizes #37

Closed youngser closed 10 years ago

youngser commented 10 years ago

Could you please revise the hsbm.game function to bypass this error, e.g., via rounding m*rho ??

> g <- hsbm.game(n,mlist,rholist,Blist,p)
Error in hsbm.list.game(n, m, rho, C, p) : 
  At sbm.c:489 : `rho' * `m' is not integer in HSBM, Invalid value
> mlist[[10]]
[1] 110
> rholist[[10]]
          [,1]      [,2]      [,3]
[1,] 0.2636364 0.5181818 0.2181818

> options(digits=22)
> mlist[[10]] * rholist[[10]]
                        [,1] [,2] [,3]
[1,] 28.99999999999999644729   57   24

> (29 / 110) * 110
[1] 28.99999999999999644729

Thanks,

gaborcsardi commented 10 years ago
n <- 1000
mlist <- list(131L, 168L, 124L, 165L, 55L, 16L, 34L, 71L, 126L, 110L)
rholist <- list(structure(c(0.557251908396947, 0.442748091603053), .Dim = 1:2), 
    structure(c(0.529761904761905, 0.470238095238095), .Dim = 1:2), 
    structure(c(0.548387096774194, 0.451612903225806), .Dim = 1:2), 
    structure(c(0.527272727272727, 0.472727272727273), .Dim = 1:2), 
    structure(c(0.581818181818182, 0.418181818181818), .Dim = 1:2), 
    structure(c(0.125, 0.5625, 0.3125), .Dim = c(1L, 3L)), structure(c(0.147058823529412, 
    0.558823529411765, 0.294117647058824), .Dim = c(1L, 3L)), 
    structure(c(0.211267605633803, 0.492957746478873, 0.295774647887324
    ), .Dim = c(1L, 3L)), structure(c(0.222222222222222, 0.515873015873016, 
    0.261904761904762), .Dim = c(1L, 3L)), structure(c(0.263636363636364, 
    0.518181818181818, 0.218181818181818), .Dim = c(1L, 3L)))
Blist <- list(structure(c(0.75, 0.25, 0.25, 0.75), .Dim = c(2L, 2L)), 
    structure(c(0.75, 0.25, 0.25, 0.75), .Dim = c(2L, 2L)), structure(c(0.75, 
    0.25, 0.25, 0.75), .Dim = c(2L, 2L)), structure(c(0.75, 0.25, 
    0.25, 0.75), .Dim = c(2L, 2L)), structure(c(0.75, 0.25, 0.25, 
    0.75), .Dim = c(2L, 2L)), structure(c(0.6, 0.4, 0.4, 0.4, 
    0.6, 0.4, 0.4, 0.4, 0.6), .Dim = c(3L, 3L)), structure(c(0.6, 
    0.4, 0.4, 0.4, 0.6, 0.4, 0.4, 0.4, 0.6), .Dim = c(3L, 3L)), 
    structure(c(0.6, 0.4, 0.4, 0.4, 0.6, 0.4, 0.4, 0.4, 0.6), .Dim = c(3L, 
    3L)), structure(c(0.6, 0.4, 0.4, 0.4, 0.6, 0.4, 0.4, 0.4, 
    0.6), .Dim = c(3L, 3L)), structure(c(0.6, 0.4, 0.4, 0.4, 
    0.6, 0.4, 0.4, 0.4, 0.6), .Dim = c(3L, 3L)))
p <- 0.1
library(igraph)
g <- hsbm.game(n,mlist,rholist,Blist,p)
gaborcsardi commented 10 years ago

Fixed in e07d0b305606c7f773963848f722a8c7bb04d1bc.