Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between d3.scale.quantize() and d3.scale.quantile()?

Tags:

From the docs, the definitions are:

quantize

..a variant of linear scales with a discrete rather than continuous range. The input domain is still continuous, and divided into uniform segments based on the number of values in (the cardinality of) the output range.

quantile

...map an input domain to a discrete range. Although the input domain is continuous and the scale will accept any reasonable input value, the input domain is specified as a discrete set of values. The number of values in (the cardinality of) the output range determines the number of quantiles that will be computed from the input domain

These both seem to map continuous input domains to a set of discrete values. Can anybody illuminate the difference?

like image 560
Jonathan Schneider Avatar asked Oct 08 '13 21:10

Jonathan Schneider


People also ask

Does 3D D3 quantize color scale?

3 D3 quantize color scale not showing the right color distribution 1 D3 Color Scale confusion in mapping continuous input to predetermined discrete bins? 1 Use the right color scale for data skewed to right

How to create a scale similar to a linear scale in D3?

The d3.scaleQuantize () function in d3.js is used to create a new scale that is similar to linear scales except that linear scales use a discrete and dis-continuous scale.

What is the difference between quantized scale and quantile scale?

The difference being that a quantized scale is a continuous function based on your discrete input. Basically: quantize allows interpolation and extrapolation, where as quantile forces the value into the subset.

What are the different scale types of data in D3?

D3 has around 12 different scale types (scaleLinear, scalePow, scaleQuantise, scaleOrdinal etc.) and broadly speaking they can be classified into 3 groups: Continuous data is typically numeric data but also includes time and dates.


1 Answers

In general terms, the difference is similar to the difference between the mean and median.

The difference is only really apparent when the number of values in the input domain is larger than the number of values in the output domain. Best illustrated by an example.

For the quantize scale, the input range is divided into uniform segments depending on the output range. That is, the number of values in the domain doesn't really matter. Hence it returns 1 for 0.2, as 0.2 is closer to 1 than 100.

The quantile scale is based on the quantiles of the input domain and as such affected by the number of values in there. The number of values in the output domain only determines how many quantiles are computed. By their very nature, the quantiles reflect the actual list of values rather than just the range. Thus, an input of 0.2 returns 100 as the corresponding quantile is closer to 100.

like image 135
Lars Kotthoff Avatar answered Sep 23 '22 05:09

Lars Kotthoff