Skip to content

get_pit_histogram(): unsorted breaks produce negative densities; num_bins = 1 returns an empty table #1219

Description

@nikosbosse

Two pre-existing problems in get_pit_histogram.forecast_quantile() surfaced during review of #1216 (they exist on main and are unrelated to that PR's changes):

  1. Unsorted breaks produce negative densities and nonsense bins. E.g. get_pit_histogram(fq, breaks = c(0.5, 0.25)) yields a bin [0.5, 0.25) with negative density. The internal present_quantiles is sorted, but the user-supplied quantiles/breaks vector is not — sorting it (or asserting sortedness) would fix this cheaply.

  2. num_bins = 1 silently returns a 0-row table. Quantile levels 0 and 1 are always injected into present_quantiles and therefore considered 'present', so the missing-quantiles fallback never triggers on that path.

Found during the automated review pass over the #1189 bug-audit PRs (directed by @nikosbosse).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions