Skip to content

use inherits in nf_preProcessMemberDataObj#1413

Merged
paciorek merged 1 commit into
develfrom
replace_an_is
Apr 7, 2024
Merged

use inherits in nf_preProcessMemberDataObj#1413
paciorek merged 1 commit into
develfrom
replace_an_is

Conversation

@paciorek
Copy link
Copy Markdown
Contributor

@paciorek paciorek commented Feb 9, 2024

Using inherits is faster than is in general, I believe.

Using it in nf_preProcessMemberDataObj can give a surprisingly large (20%) speedup in a case where we are building many simple samplers. In code below buildMCMC takes 28 sec when using inherits and 36 sec when using is.

n <- 10000
code <- nimbleCode({
    for(i in 1:n) {
        y[i]~dpois(mu[i])
        mu[i]~dnorm(mu0,sd=sigma)
    }
    mu0 ~ dnorm(0,sd=10)
    sigma ~ dunif(0, 10)
})

m <- nimbleModel(code, data = list(y = rpois(n,1)), constants = list(n=n))
system.time(conf <- configureMCMC(m, useConjugacy=FALSE))
system.time(mcmc <- buildMCMC(conf))

@paciorek paciorek merged commit 7224632 into devel Apr 7, 2024
@paciorek paciorek deleted the replace_an_is branch April 7, 2024 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant