new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

D3 · all subjects

d3-scale/quantile

11 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

scaleQuantile constructor signature

scaleQuantile(domain, range) constructs a new quantile scale with the specified domain and range. If either domain or range is not specified, each defaults to the empty array. The quantile scale is invalid until both a domain and range are specified.

Quantile scale domain requirements

The domain array must not be empty and must contain at least one numeric value. NaN, null, and undefined values are ignored and not considered part of the sample population. If the elements in the given array are not numbers, they will be coerced to numbers. A copy of the input array is sorted and stored internally.

Quantile scale range requirements

The range array must not be empty and may contain any type of value. The number of values in the range array (its cardinality or length) determines the number of quantiles that are computed. For example, to compute quartiles, the range must be an array of four elements.

quantile(value) method

Given a value in the input domain, returns the corresponding value in the output range. Example: color(3000) returns "#eff3ff", color(4000) returns "#6baed6", color(5000) returns "#08519c".

quantile.invertExtent(value) method

Returns the extent of values in the domain [x0, x1] for the corresponding value in the range: the inverse of quantile(). For example, color.invertExtent("#eff3ff") returns [2700, 3475], color.invertExtent("#6baed6") returns [3800, 4300], color.invertExtent("#08519c") returns [4950, 6300]. This method is useful for interaction, such as determining the value in the domain that corresponds to the pixel location under the mouse.

quantile.domain(domain) method

If domain is specified, sets the domain of the quantile scale to the specified set of discrete numeric values and returns this scale. If domain is not specified, returns the scale's current domain (the set of observed values), sorted internally.

quantile.range(range) method

If range is specified, sets the discrete values in the range and returns this scale. If range is not specified, returns the current range.

quantile.quantiles() method

Returns the quantile thresholds as an array. If the range contains n discrete values, the returned array will contain n - 1 thresholds. Values less than the first threshold are considered in the first quantile; values greater than or equal to the first threshold but less than the second threshold are in the second quantile, and so on. Example: color.quantiles() returns [3475, 3800, 4300, 4950].

quantile.copy() method

Returns an exact copy of this scale. Changes to this scale will not affect the returned scale, and vice versa.

Quantile scale overview

Quantile scales map a sampled input domain to a discrete range. The domain is considered continuous and thus the scale will accept any reasonable input value; however, the domain is specified as a discrete set of sample values. The number of values in the output range determines the number of quantiles that will be computed from the domain. To compute the quantiles, the domain is sorted and treated as a population of discrete values.

Quantile scale example usage

Example: const color = d3.scaleQuantile(penguins.map((d) => d.body_mass_g), d3.schemeBlues[5]); This creates a quantile scale using penguin body mass as the domain and a color scheme as the range.

Give your agent this brain