Default violin bandwidth misnamed: should be Scott's, not Silverman's
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 18.3k
- フォーク
- 2k
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 28
説明
There seems to be a naming bug in code and reference documentation for violin plots. What is referred to as "Silverman's rule of thumb" seems to actually be "Scott's rule of thumb" -- a slight variant of Silverman's.
Replacing two strings seems like it would fix this incorrect name.
Bug in code
Code at src/traces/violin/calc.js#L99 notes:
// Default to Silveman's rule of thumb
// - https://stats.stackexchange.com/a/6671
// - https://en.wikipedia.org/wiki/Kernel_density_estimation#A_rule-of-thumb_bandwidth_estimator
// - https://github.com/statsmodels/statsmodels/blob/master/statsmodels/nonparametric/bandwidths.py
function silvermanRule(len, ssd, iqr) {
var a = Math.min(ssd, iqr / 1.349);
return 1.059 * a * Math.pow(len, -0.2);
}
Bug in docs
Likewise, reference documentation at https://plotly.com/javascript/reference/#violin-bandwidth notes:
bandwidth
Parent: data[type=violin]
Type: number greater than or equal to 0
Sets the bandwidth used to compute the kernel density estimate. By default, the bandwidth is
determined by Silverman's rule of thumb.
The inconsistency
Code comments referenced above link to https://github.com/statsmodels/statsmodels/blob/master/statsmodels/nonparametric/bandwidths.py, which includes these excerpts:
def bw_scott(x, kernel=None):
"""
Scott's Rule of Thumb
...
"""
...
return 1.059 * A * n ** (-0.2)
def bw_silverman(x, kernel=None):
"""
Silverman's Rule of Thumb
...
"""
...
return .9 * A * n ** (-0.2)
Scott's uses 1.059 where Silverman's uses 0.9. Scott's is the more common default bandwidth -- see e.g. https://stat.ethz.ch/R-manual/R-devel/library/stats/html/bandwidth.html.
So the calc.js function gets the implementation right, but uses the incorrect name. It uses 1.059 but incorrectly calls it Silverman's, when it should be Scott's per above.
So it seems the function name should be scottRule (or at least not silvermanRule), and the docs should be updated accordingly.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
src/traces/violin/calc.js の silvermanRule 関数から始め、plotly.com/javascript/reference/#violin-bandwidth にある violin の bandwidth のリファレンス項目を確認してください。1.059 の式が Scott's rule であることを検証し、その後、関数名とドキュメント名を一貫して更新してください。コードコメント、関数名、リファレンステキストのすべてで Scott's rule を示し、計算を変更していなければ完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- data-visualization, documentation
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 56/100