Default violin bandwidth misnamed: should be Scott's, not Silverman's
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- JavaScript
- Star
- 18.3k
- Fork
- 2k
- Merge trung bình
- 2 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 28
Mô tả
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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu tại src/traces/violin/calc.js, ở hàm silvermanRule, và xem lại mục tham chiếu về bandwidth của violin tại plotly.com/javascript/reference/#violin-bandwidth. Xác minh rằng công thức 1.059 là Scott's rule, sau đó cập nhật nhất quán tên hàm và tên trong tài liệu. Hoàn tất khi chú thích trong mã, tên hàm và nội dung tham chiếu đều xác định đó là Scott's rule mà không thay đổi phép tính.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript
- Lĩnh vực
- data-visualization, documentation
- Loại issue
- Lỗi
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 56/100