discretize1D: Discretize one-dimensional continuous data into bins

Description Usage Arguments Details Value Examples

View source: R/discretization.measure.R

Description

The function of discretize1D is used to assign the observations of a set of continuous random variables to bins, and returns a corresponding one-dimensional count table. Two of the most common discretization methods are available: "uniform width" and "uniform frequency".

Usage

1
discretize1D(x, algorithm = c("uniform_width", "uniform_frequency"))

Arguments

x

a numeric vector of the random variable x.

algorithm

two discretization algorithms are available, "uniform_width" is the default.

Details

Uniform width-based method ("uniform_width") divides the continuous data into N bins with equal width, while Uniform frequency-based method ("uniform_frequency") divides the continuous data into N bins with (approximate) equal count number. By default in both methods, the number of bins N is initialized into a round-off value according to the square root of the data size.

Value

discretize1D returns a one-dimensional count table.

Examples

1
2
3
4
5
6
7
8
# a numeric vector corresponding to a continuous random variable
x <- c(0.0, 0.2, 0.2, 0.7, 0.9, 0.9, 0.9, 0.9, 1.0)

# corresponding count table estimated by "uniform width" algorithm
discretize1D(x, "uniform_width")

# corresponding count table estimated by "uniform frequency" algorithm
discretize1D(x, "uniform_frequency")

Example output

    [0,0.333] (0.333,0.667]     (0.667,1] 
            3             0             6 

1 2 3 
3 3 3 

Informeasure documentation built on Nov. 8, 2020, 7:20 p.m.