Skip to content

[rand.dist.samp.plinear] Fix densities() return size - #9377

Open
firmiana402 wants to merge 1 commit into
cplusplus:mainfrom
firmiana402:editorial/piecewise-linear-densities-size
Open

firmiana402 wants to merge 1 commit into
cplusplus:mainfrom
firmiana402:editorial/piecewise-linear-densities-size

Conversation

@firmiana402

Copy link
Copy Markdown
Contributor

Correct the specified size of the vector returned by piecewise_linear_distribution::densities() from n to n + 1, matching the stated index range 0, ..., n.

piecewise_linear_distribution has one density per interval boundary (n + 1 values). [rand.dist.samp.plinear] explicitly states:

Unless specified otherwise, the remaining $n + 1$ distribution parameters are calculated as $\rho_k = w_k / S$ for $k = 0, \dotsc, n$, […]

This differs from piecewise_constant_distribution, which has one density per subinterval and therefore only n densities.

The incorrect size was already present in the repository's initial commit, d8fb8cf (2011).

@jensmaurer

Copy link
Copy Markdown
Member

This looks correct, given that we iterator $rho$ from 0 to $n$. @jwakely ?

@eisenwave eisenwave added the P1-Important Misapplication of paper, malformed code, internal inconsistencies label Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1-Important Misapplication of paper, malformed code, internal inconsistencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants