Keywords - Function groups - @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Library: smoother
See also: bindata binweights

Quantlet: binlindata
Description: linear binning for univariate data, given the binwidth and optionally the origin of the bin grid. The smallest grid with width d that covers the data is found and the data are binned to this grid using the linear binning rule.


Usage: {bing, binc} = binlindata(x, d{, orig})
x n x 1 vector, the data to be binned
d optional scalar (d > 0), representing the binwidth
orig optional scalar, corresponds to the origin of the bingrid, default = 0.
bing m x 1 vector, the equidistant bingrid
binc m x 1 vector, the bincounts at the grid points


n = 6000
x = normalmix(n,w,mu,sigma)
x = round(x,1)
d = 0.1
{bing, binc} = binlindata(x, d)

Generates 6000 variates from a normal mixture example
distribution, rounds them, and bins them to a grid.
The bin grid and the corresponding bin counts are shown.
Note that the bin counts are integers when data are rounded by round(x,1).
This is done to get rid of floating point inaccuracies
and they sum up to the total sample size.
If the data are not rounded (i.e. x = round(x,1) is commented
out) then the bin counts are no longer integers but still
sum up to the total sample size.

Author: J.-U. Scheer, 20020406 license MD*Tech
(C) MD*TECH Method and Data Technologies, 05.02.2006