Skip to content

height_percentile API ambiguity: R defaults/plots imply 0–1 but LUT/API should be 0–100 #25

@dewittpe

Description

@dewittpe

Summary

We want the end-user API for height_percentile to be 0–100 (percentile points). The C++ lookup and LUT are already on a 0–100 scale, but several R entry points and plotting helpers imply a 0–1
scale (e.g., defaults of 0.5 and dividing by 100). This creates an ambiguous API and can silently mislead users.

Current behavior (inconsistent)

  • C++ lookup expects 0–100; LUT values are 5–95.
    • src/blood_pressure.cpp:112-115 matches against LUT col 5 values (5–95).
  • R docs for bp distribution functions say 0–100.
    • R/bp_distribution.R:51-52
  • But R defaults and plotting imply 0–1:
    • bp_chart() default height_percentile = 0.5 (R/bp_charts.R:50)
    • bp_cdf.default() default height_percentile = 0.50 (R/bp_cdf_plot.R:89)
    • bp_cdf.pedbp_p_bp() and .pedbp_q_bp() divide stored params by 100 before re-calling bp_cdf() (R/bp_cdf_plot.R:63-78)

Why this matters

If the contract is 0–100, then 0.95 means the 0.95th percentile (not the 95th). However, default values like 0.5 are likely intended to mean the median, which would be 50. The current mix of
0–1 defaults and 0–100 LUT usage makes the API ambiguous and can yield surprising results.

Proposed direction

Standardize the end-user API to 0–100 throughout:

  • Update R defaults (0.5 -> 50) and examples/tests accordingly.
  • Remove / 100 conversions in bp_cdf.* (or otherwise ensure a single consistent scale).
  • Optionally emit a warning if height_percentile is in [0, 1], since that often indicates a user is thinking in 0–1 scale.

Suggested warning

If height_percentile is between 0 and 1 (exclusive), warn that the API expects 0–100 and that the value is treated as percentile points, e.g., 0.95 = 0.95th percentile.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions