Skip to content

How to make a C library accessible to the Csnippet #156

Answered by kingaa
MarieAugerMethe asked this question in Q&A
Discussion options

You must be logged in to vote

The following updates the codes above for pomp versions ≥ 4. The codes below link the truncated_normal library using C snippets. This corresponds to my option two above. Note that things have gotten a bit simpler by version 4 of pomp.

ricker() |>
  simulate(
    rmeasure=Csnippet("
        y = rnorm(N,1);
        y = (y > 0) ? y : 0;
        "),
    dmeasure=Csnippet("
        lik = truncated_normal_a_pdf(y,N,1,0);
        if (give_log) lik = log(lik);"),
    statenames="N",
    globals="#include \"truncated_normal.h\"",
    shlib.args="truncated_normal.o"
) -> rick2

replicate(n=10,
  rick2 |>
    pfilter(Np=1000) |>
    logLik()
) |>
  logmeanexp(se=TRUE)

The two files mentioned (trunc…

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by kingaa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
3 participants
Converted from issue

This discussion was converted from issue #68 on August 25, 2021 12:42.