pdf(uniform(a,b),x) returns half the correct density at both endpoints, so pdf(uniform(0,1),0) is 0.5 instead of 1

Open Beginner friendly
#362 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
r, rust

Research direction

Start by locating the Rust implementation of pdf(uniform(a,b), x) and its tests; the issue does not name specific files. Check how the support interval handles its endpoints, then add or update tests for both endpoints and an interior value across intervals of different widths. Done when endpoint densities equal 1/(b-a), matching the stated dunif results.

Written by the indexing model from the issue text.

Description

area/statistics good first issue help wanted kind/wrong-result severity/4-minor

pdf(uniform(a,b), x) returns half the correct density at both endpoints x = a and x = b. The interior is right, so the density is not constant on its own support.

library(rssn)
compute(parse_term("pdf(uniform(0,1), 0.5)"))$value  # 1    (correct)
compute(parse_term("pdf(uniform(0,1), 0)"))$value    # 0.5  (wrong)
compute(parse_term("pdf(uniform(0,1), 1)"))$value    # 0.5  (wrong)
compute(parse_term("pdf(uniform(0,2), 0)"))$value    # 0.25 (wrong)

R gives dunif(0,0,1) = 1, dunif(1,0,1) = 1 and dunif(0,0,2) = 0.5. The uniform density is 1/(b-a) on the closed interval [a,b], so it must be 1 at both ends of [0,1] and 0.5 at both ends of [0,2].

The mechanism is a x > a && x < b style strict-interval test that falls through to a different branch exactly at the boundary; the returned value is exactly 1/(2(b-a)), i.e. the density is halved at x == a and x == b only.

Expected: pdf(uniform(a,b), a) = pdf(uniform(a,b), b) = 1/(b-a), matching dunif.

rssn 0.3.0, R 4.6.2 binding, Windows x86_64.

Dominant language
Rust
Stars
36
Forks
3
Avg merge
14h 51m
Merged PRs (30d)
29

Getting set up

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.

More from Apich-Organization/rssn

All issues in Apich-Organization/rssn

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.