[BUG]: `math/base/special/gammainc` is off by up to 0.03 for x > 1000 when a is close to x
維護者通常 1 天內回覆
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript
- 領域
- backend, testing-qa
研究方向
Read lib/node_modules/@stdlib/math/base/special/gammainc/lib/tgamma_i_large_x_series.js and the corresponding C implementation in src/main.c; the issue identifies the off-by-one initialization in both. Start by checking the four reproduction cases against the expected values, then inspect the existing tests for these implementations. Done when the JavaScript and C results match the expected values for large x with a near x, and related distribution results are corrected.
由索引模型根據 Issue 內容生成。
描述
Description
Encountered an error when evaluating gammainc with x > 1000 and a near x. The large-x asymptotic series (tgamma_i_large_x_series.js) starts its falling factorial at a instead of a - 1, so results are off by up to a few percent. This propagates to stats/base/dists/poisson/cdf, chisquare/cdf, gamma/cdf and others for large parameters.
In lib/node_modules/@stdlib/math/base/special/gammainc/lib/tgamma_i_large_x_series.js, var a = a1; should be var a = a1 - 1.0;, matching Boost's incomplete_tgamma_large_x_series (a_poch(a - 1)). With that one-line change the four values below match SciPy. The C implementation in src/main.c (ac = a; at line 703, in the same series) has the same off-by-one.
Found with a differential-testing tool; the report was drafted with AI assistance and reviewed and edited by me.
Related Issues
None.
Questions
No.
Demo
https://trackoor.github.io/stdlib-gammainc-large-x-repro/ (source: https://github.com/trackoor/stdlib-gammainc-large-x-repro). It shows the first three values from the jsDelivr ESM build; the chisqCDF value is only wrong in the npm build.
Reproduction
npm i @stdlib/[email protected] @stdlib/[email protected] @stdlib/[email protected]- save as
t.jsand runnode t.js:
var gammainc = require( '@stdlib/math-base-special-gammainc' );
var poissonCDF = require( '@stdlib/stats-base-dists-poisson-cdf' );
var chisqCDF = require( '@stdlib/stats-base-dists-chisquare-cdf' );
console.log( gammainc( 1367.3436948118986, 1409.203708740708 ) );
console.log( gammainc( 1001, 1000.5, true, true ) );
console.log( poissonCDF( 999, 1001 ) );
console.log( chisqCDF( 2500, 2400 ) );
Expected Results
0.13190499189857086
0.489491914600245
0.48318854707021375
0.9241270884571916
(SciPy 1.10.1: gammainc(1409.203708740708, 1367.3436948118986), gammaincc(1000.5, 1001), poisson.cdf(999, 1001), chi2.cdf(2500, 2400))
Actual Results
0.09952119051642438
0.501850998882592
0.49530155533410974
0.9231500432608719
Version
@stdlib/math-base-special-gammainc 0.3.1; same code on develop 734972c
Environments
Node.js
Browser Version
Chrome 152 for the demo page; the report itself uses Node.js.
Node.js / npm Version
v26.13.0
Platform
Linux
Checklist
- Read and understood the Code of Conduct.
- Searched for existing issues and pull requests.
Credit: https://ucsbplse.github.io/
- 主要語言
- JavaScript
- 星號
- 6k
- 分支
- 1.3k
- 平均合併
- 1 天 21 小時
- 30 天內合併 PR
- 224
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
stdlib-js/stdlib 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
stdlib-js/stdlib#16655 · 1 則留言 ·
維護者通常 1 天內回覆
-
Fix JavaScript lint errors可能已有人在做 @protestershankar 於 5 天前認領。 未關閉Good First Issue
難度 2/5 1-3 小時 新手友好度 82/100
stdlib-js/stdlib#16563 · 3 則留言 ·
維護者通常 1 天內回覆
-
Fix C lint errors可能已有人在做 @raus7n 於 14 天前認領。 未關閉Good First Issue
難度 1/5 1 小時以內 新手友好度 82/100
stdlib-js/stdlib#16454 · 1 則留言 ·
維護者通常 1 天內回覆
-
Fix JavaScript lint errors可能已有人在做 @Devansh-18155 於 39 天前認領。 未關閉Good First Issue
難度 1/5 1 小時以內 新手友好度 82/100
stdlib-js/stdlib#15970 · 1 則留言 ·
維護者通常 1 天內回覆
-
Fix JavaScript lint errors可能已有人在做 @lb1192176991-lab 於 44 天前認領。 未關閉Good First Issue
難度 1/5 1 小時以內 新手友好度 90/100
stdlib-js/stdlib#15831 · 2 則留言 ·
維護者通常 1 天內回覆
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 69/100
維護者通常 1 天內回覆
-
automation chore ci-cd consistency developer-experience difficulty: easy discoverability documentation enhancement github-actions good first issue help wanted hygiene priority: P3 seo shell yaml
難度 1/5 1 小時以內 新手友好度 76/100
-
bug
難度 2/5 1-3 小時 新手友好度 84/100
swc-project/swc-next-issues#394 ·
-
難度 1/5 1-3 小時 新手友好度 88/100
githubnext/gh-aw-workshop#5790 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
adobe/helix-tools-website#480 ·
維護者通常 1 天內回覆