stan-dev / stan-dev/math

relax type identity between constrained variable and target log density

Open
#1,733 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

code cleanup good first issue
Dominant language
C++
Stars
839
Forks
220
Avg merge
2d 4h
Merged PRs (30d)
14

Description

Description

In the constrain_XXX functions applied to map unconstrained parameters to parameters in Stan, the value being constrained is required to be the same type as the log density target being incremented. These functions should allow the two types to vary independently. The target will always be at least double, whereas the variable being constrained might be int when used in the language.

Example

template <typename T, typename L, typename U>
inline return_type_t<T, L, U> lub_constrain(const T& x, const L& lb,
                                            const U& ub, T& lp) {

Expected Output

For all of the XXX_constrain functions with an lp argument, the types should be generalized to look like this:

template <typename T, typename L, typename U, typename L>
inline return_type_t<T, L, U> lub_constrain(const T& x, const L& lb,
                                            const U& ub, L& lp)

On the identity constrain version, that means the lp argument needs to be uncommented to support type inference.

Current Version:

v3.1.0

Contributor guide

Open the contributing guide

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

Start by locating the constrain_XXX functions with an lp argument, including the identity constrain variant. Review their template parameters and how the lp argument is typed; done means all such functions allow the constrained value and target log density to use independent types, with identity constrain type inference supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.