From the docs, the definitions are:
..a variant of linear scales with a discrete rather than continuous range. The input domain is sti
The difference is, as far as I can tell, simply that statistically quantiles are finite, equal, and evenly-distributed discrete blocks/buckets into which your results simply fall. 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.
So, for example, if a student's calculated grade is 81.7% in a quantized scale, a quantiles scale of percentiles would simply say that it is of the 81st percentile. There's no room for flexibility there.
I had this same question myself. So I made a visualization to help understand how they work.
Coloring Maps has a great visual explanation.
Quantize:
Quantile:
On the scatter plot, the previously horizontal bars are now vertical as the colors of each place is determined by its rank, not value.
Here's a code snippet in D3 v4 that shows different results in quantize and quantile.
const purples = [
'purple1',
'purple2',
'purple3',
'purple4',
'purple5'
]
const dataset = [1, 1, 1, 1, 2, 3, 4, 5] // try [1, 2, 3, 4, 5] as well
const quantize = d3.scaleQuantize()
.domain(d3.extent(dataset)) // pass the min and max of the dataset
.range(purples)
const quantile = d3.scaleQuantile()
.domain(dataset) // pass the entire dataset
.range(purples)
console.log(quantize(3)) // purples[3]
console.log(quantile(3)) // purples[4]
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.