gpt4 book ai didi

d3.js - d3.scale.quantile 是如何工作的?

转载 作者:行者123 更新时间:2023-12-03 21:19:24 24 4
gpt4 key购买 nike

这句话的含义是什么?

quantize = d3.scale.quantile().domain([0, 15]).range(d3.range(9));

我看到域是:

0 - 0
1 - 15



范围是从 0 到 8 和 quantize.quantiles
0 - 1.6
1 - 3.3
2 - 4.9
3 - 6.6
4 - 8.3
5 - 9.9
6 -11.6
7 -13.3

quantize.quantiles 的值是如何计算的?我试着调用 quantize(2)但结果是 1 . quantile如何工作?

最佳答案

分位数尺度的动机是获得代表数据集中值的实际分布的类。因此,有必要在构建过程中为其提供完整的值列表。然后,比例尺将输入域(由这些值定义)拆分为区间(分位数),使得大约相同数量的值落入每个区间。
从文档中:

To compute the quantiles, the input domain is sorted, and treated as a population of discrete values.


因此,在指定域时,我们将整个值列表提交给比例:
var scale = d3.scale.quantile()
.domain([1, 1, 2, 3, 2, 3, 16])
.range(['blue', 'white', 'red']);
如果我们然后运行:
scale.quantiles()
它将输出 [2, 3] ,这意味着我们的值群被分成三个子集,分别由“蓝色”、“白色”和“红色”表示:
[1, 1] [2, 2] [3, 3, 16]
请注意,当您要显示的数据中存在异常值时,应避免使用此比例。在上面的示例中,16 是落入上分位数的异常值。它被分配了与 3 相同的类,这可能不是所需的行为:
scale(3)   // will output "red"
scale(16) // will output "red"

关于d3.js - d3.scale.quantile 是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10579944/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com