d3.scale.quantile如何工作? [英] How does d3.scale.quantile work?

查看:382
本文介绍了d3.scale.quantile如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个语句的意思是什么?

What is the meaning of this statement?

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

我看到的域名是:


0 - 0

1 - 15

0 - 0
1 - 15

范围为0到8和quantize.quantiles

range is from 0 to 8 and 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(2),但结果是 1 quantile 如何工作?

How are the values to quantize.quantiles calculated ? I tried to call quantize(2) but the result was 1. How does quantile work?

推荐答案

分位数量表的动机以获得代表数据集中的值的实际分布的类。因此,有必要在构造期间提供它的值的完整列表。然后,尺度将输入域(由这些值定义)分割成间隔(分位数),使得大约相同数量的值落入每个间隔。

The motivation of the quantile scale is to obtain classes which are representative of the actual distribution of the values in the dataset. Therefore, it is necessary to provide it during construction with the full list of values. The scale then splits the input domain (defined by these values) into intervals (quantiles), so that about the same number of values falls into each of the intervals.

从文件:


要计算分位数,输入域被排序,并被视为离散值的群体。

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()

这意味着我们的值的人口被分为这三个子集:

It will output [2, 3] which means that our population of values was split into these three subsets:

[1, 1] [2, 2] [3, 3, 16]

请注意,当数据中存在异常值时,想显示。在上述示例中,16是落入上分位数的离群值。它被分配与3相同的类,这可能不是所需的行为:

Note that this scale should be avoided when there are outliers in the data which you want to show. In the above example 16 is an outlier falling into the upper quantile. It is assigned the same class as 3, which is probably not the desired behavior:

scale(3)   // will output "red"
scale(16)  // will output "red"

这篇关于d3.scale.quantile如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆