stan-dev / stan-dev/math

CDFs for discrete variables and PMFs only allow integer values

Open
#2,467 20 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

Functions such as bernoulli_cdf and bernoulli_pmf only accept integer values. This is mathematically imprecise, as CDFs and PMFs should be defined for all real numbers (e.g., pbinom and dbinom in R accept non-integer values).

This is a problem, e.g., if you have a matrix Y of values where each column has a different distribution (e.g., first column is Gaussian, second column is Bernoulli). Such constructs are necessary to create a general Gaussian copula function.

Example

binomial_cdf(0.5, 0.75);

Expected Output

0.25

Currently, no code will compile if a non-integer value is input as the first argument to binomial_cdf(0.5, 0.75).

Current Version:

v4.0.1

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 C++ implementations and tests for bernoulli_cdf, bernoulli_pmf, and binomial_cdf. Inspect how the first argument's type is constrained, then identify the other discrete CDF and PMF functions that need the same treatment. Done means binomial_cdf(0.5, 0.75) compiles and returns 0.25, with tests covering the updated behavior.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.