Description Usage Arguments Details Value Examples
View source: R/discretization.measure.R
The function of discretize2D is used to assign the observations of two sets of continuous random variables to bins, and returns a corresponding two-dimensional count table. Two of the most common discretization methods are available: "uniform width" and "uniform frequency".
1 | discretize2D(x, y, algorithm = c("uniform_width", "uniform_frequency"))
|
x |
a numeric vector of the random variable x. |
y |
a numeric vector of the random variable y. |
algorithm |
two discretization algorithms are available, "uniform_width" is the default. |
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.
discretize2D returns a 2-dimensional count table.
1 2 3 4 5 6 7 8 9 | # two numeric vectors that correspond to two continuous random variables
x <- c(0.0, 0.2, 0.2, 0.7, 0.9, 0.9, 0.9, 0.9, 1.0)
y <- c(1.0, 2.0, 12, 8.0, 1.0, 9.0, 0.0, 3.0, 9.0)
# corresponding count table estimated by "uniform width" algorithm
discretize2D(x,y, "uniform_width")
# corresponding count table estimated by "uniform frequency" algorithm
discretize2D(x,y, "uniform_frequency")
|
[0,4] (4,8] (8,12]
[0,0.333] 2 0 1
(0.333,0.667] 0 0 0
(0.667,1] 3 1 2
1 2 3
1 1 1 1
2 1 1 1
3 1 1 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.