From the docs, the definitions are:
..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.
...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?
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
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With