Skip to content

Some built in stan functions are missing #10

Open

Description

@nsiccha

An incomplete list of missing built in stan functions or signatures and how to add some of them:

@deffun begin 
    positive_infinity()::real
    negative_infinity()::real
    logit(::real)::real
    bernoulli_lpmf(::int, theta)
    bernoulli_lpmf(::int[n], theta)
    bernoulli_rng(::vector[n])::int[n]
    bernoulli_lpmfs(y::int, args...) = bernoulli_lpmf(y, args...)
    bernoulli_lpmfs(y::int[n], args...) = jbroadcasted(bernoulli_lpmfs, y, args...)
end

Activity

  1. changed the title [-]`mdivide_left_tri_low` is missing[/-] [+]Some built in stan functions are missing[/+] on Jul 25, 2025
  2. added 2 commits that reference this issue on Oct 14, 2025
  3. nsiccha commented on Oct 16, 2025

    @nsiccha
    OwnerAuthor

    @WardBrian: Not that you should care about me fixing this issue - but I think you're the person who could answer the following question immediately:

    Is there an easy way to write out all built-in Stan functions and their supported signatures - ideally with the sizes on top of their return types?

    If this could be automated (e.g. via stanc), I could ensure that StanBlocks.jl is always up to date with Stan proper.

  4. WardBrian commented on Oct 16, 2025

    @WardBrian

    stanc —dump-stan-math-signatures does this for all the functions except the variadics (though I’m not sure what you mean by sizes?)

  5. nsiccha commented on Oct 17, 2025

    @nsiccha
    OwnerAuthor

    Ah - apologies!

    If you look at one of the examples that are currently in the top comment, you'll see this:

    bernoulli_rng(::vector[n])::int[n]

    StanBlocks.jl needs to know how the size information of the arguments to the function propagate to its return value to be able to infer types and dimensions of all expressions.

    I must assume that stanc may not actually have that information? Because only the type and "rank" (i.e. is it int, or array[] int, or array[,] int) is checked at compile time by stanc? And then the compatibility of any argument/operator arguments is only checked at runtime by appropriate checks on the underlying (e.g.) Eigen objects?

  6. pinned this issue on Oct 17, 2025
  7. WardBrian commented on Oct 17, 2025

    @WardBrian

    Correct, stanc does not have that information. That said, I think in almost every case the requirement is that the sizes be the same for all argumentd, with a few notable exceptions like matmuls

  8. nsiccha commented on Oct 17, 2025

    @nsiccha
    OwnerAuthor

    That said, I think in almost every case the requirement is that the sizes be the same for all argumentd, with a few notable exceptions like matmuls

    Yeah - that was my hope as well! :)

    Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions