/*! * Copyright (c) Microsoft. All rights reserved. * Licensed under the MIT license. See LICENSE file in the project. */ /** * The Bin holds an array of values that match the bounding criteria, * along with an additional pair of properties indicating that bounding. */ export interface Bin extends Array { /** * Minimum _computed_ value for the bin */ x0: number; /** * Maximum _computed_ value for the bin */ x1: number; } /** * A Histogram is just an array of Bins. * This follows the d3 format, so these outputs can be used as drop-ins to * any code that expects a d3-style histogram. */ export type Histogram = Array; /** * Creates a histogram from an array of objects. * The histogram will be populated with numeric values. * If your input data is not numeric, supply an accessor function. * By default, a standard equal-interval histogram will be created. * If the quantize parameter is set, it will instead use quantiles (i.e., equal-length bins). * If you are quantizing, you can also set a smooth parameter to indicate that breaks in the data should try to minimize variance. * * Note on quantiles: the bin count and length are ideals, but not guaranteed. * The way the quantiles are calculated, a precise number of bins can't be guaranteed unless you will accept empty bins. * For example, if your dataset is [1,1,1,1,1,2,2], you will always only get back two bins. * Depending on the data distribution, we also may not be able to assure each bin is the same length as the others. * Using the same example dataset, here we would have one bin with 5 items, and the other with 2. * We _could_ split them evenly and put some of the 1s in the 2 bin, but that seems less preferable. * */ export declare const histogram: (data: any[], bins: number, accessor?: (d: any) => any, quantize?: boolean, smooth?: boolean) => Histogram;