PoonLab / Kaphi

Kernel-embedded ABC-SMC for phylodynamic inference
GNU Affero General Public License v3.0
4 stars 2 forks source link

Re-implementation of kernel in native R failing unit tests #143

Closed ArtPoon closed 5 years ago

ArtPoon commented 5 years ago

To repro:

require(Kaphi)
require(igraph)  # need to add this as package dependency
    config <- list(
        dist='Kaphi::kernel.dist(x, y, decay.factor=0.5, rbf.variance=2.5, sst.control=1, norm.mode=NONE)',
        decay.factor=0.5,
        rbf.variance=2.5,
        sst.control=1.0,
        norm.mode="NONE"
    )
    nwk.1 <- "(t4:0.2848235269,t3:0.2848235269);"
    nwk.2 <- "(t1:0.04204444404,t2:0.04204444404);"
    tr1 <- parse.input.tree(nwk.1, config)
    tr2 <- parse.input.tree(nwk.2, config)

    delta.1 <- 0.5 * exp(-2*(0.2848235269-0.04204444404)^2/2.5) * (1+0.5) * (1+0.5)
    result <- utk(tr1, tr2, config)
# delta.1 == result passes

    nwk.1 <- "((t4:0.2848235269,t3:0.2848235269):0.6005581596,t1:0.8853816865);"
    nwk.2 <- "((t1:0.04204444404,t2:0.04204444404):1.28616494,t3:1.328209384);"
    tr1 <- parse.input.tree(nwk.1, config)
    tr2 <- parse.input.tree(nwk.2, config)

    result <- utk(tr1, tr2, config)
    delta.2 <- 0.5 * exp(-((0.6005581596-1.28616494)^2+(0.8853816865-1.328209384)^2)/2.5) * (1+delta.1) * (1+0.5)
    expected <- delta.1 + delta.2

# expected == result fails (2.264361 and 1.689797, respectively)
ArtPoon commented 5 years ago

Beh - forgot to add sst.control to cached values