stan-dev / stan-dev/stanc3

Automatically generate code for forward sampling from model

Open
#174 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
OCaml
Stars
160
Forks
59
Avg merge
21h 45m
Merged PRs (30d)
26

Description

Using a dependence analysis, it should be easy to determine whether a Stan model represents a DAG. That should be a check that should be integrated with @rybern 's factor graph analysis.

If we determine that a Stan program is a DAG, then we can automatically generate code for forward sampling from the model, which is super useful for prior predictive checks and SBC. The idea is basically just to replace ~-statements (and appropriate target increments) with assignments of rng draws. The trick will be to try to transform to the code we want and to then type check before committing to make sure the appropriate rngs exist. Otherwise, we can throw an error suggesting that the user implement the needed rng and submit a PR to Stan Math.

One design decision will be what to do with covariates in the data block (which never appear to the left of a ~-statement). One natural thing to do would be to draw them from a sort of uniform distribution. It might be more useful though for some applications to draw them from a normal distribution. Another option is not to draw them at all but to leave them as IO calls. Perhaps we should offer multiple options to the users.

Note that this feature would be super useful for automatically generating synthetic datasets from models to improve our test coverage.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by locating the dependence and factor graph analyses, then assess how DAG detection, RNG generation, type checking, and covariate handling would fit together; done would require an agreed design and implementation plan.

Written by the indexing model from the issue text.

Assessment

Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
15/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.