[Repo Assist] Fix ChiSquared.InvCDF scale parameter bug; add InvCDF tests#368
Draft
github-actions[bot] wants to merge 2 commits intodeveloperfrom
Draft
Conversation
ChiSquared.InvCDF delegates to Gamma.InvCDF, but was passing beta = 1/2 (rate) while FSharp.Stats Gamma uses the *scale* parameterisation (Mean = alpha * scale). The correct scale for Chi-squared(dof) = Gamma(alpha=dof/2, scale=2) is 2.0, not 0.5. The wrong value caused InvCDF to return quantiles that were roughly 4× too small. Also adds a testList "ChiSquared.InvCDF tests" with: - boundary checks (p=0 → 0, p=1 → +∞) - round-trip tests (CDF(InvCDF(p)) ≈ p) at p=0.5, 0.95, 0.01 - known-value tests derived from the existing CDF reference values All 1201 tests pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
21 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated PR from Repo Assist.
Problem
ChiSquared.InvCDFreturned drastically wrong quantiles. For example,ChiSquared.InvCDF 20. 0.1returned ≈ 3.11 instead of the correct ≈ 12.44.Root cause
ChiSquared.InvCDFdelegates toGamma.InvCDF, but was passingbeta = 1/2whileFSharp.Stats.Distributions.Continuous.Gammauses the scale parameterisation (Mean = α × scale). The chi-squared distribution corresponds toGamma(α = dof/2, scale = 2), so the correct value isbeta = 2.0, not0.5.All 1201 existing tests continue to pass; 7 new tests added for
ChiSquared.InvCDF.Closes part of #262 (InvCDF gaps).