Class "distributionH"
desfines an histogram object
The class describes a histogram by means of its cumulative distribution
function. The methods are develoved accordingly to the L2 Wasserstein
distance between distributions.
A histogram object can be created also with the function distributionH(...)
, the costructor function for creating an object containing the description of
a histogram.
# S4 method for distributionH
initialize(
.Object,
x = numeric(0),
p = numeric(0),
m = numeric(0),
s = numeric(0)
)distributionH(x = numeric(0), p = numeric(0))
A distributionH
object
the type ("distributionH")
a numeric vector. it is the domain of the distribution (i.e. the extremes of bins).
a numeric vector (of the same lenght of x). It is the cumulative distribution function CDF.
(optional) a numeric value. Is the mean of the histogram.
(optional) a numeric positive value. It is the standard deviation of a histogram.
Objects can be created by calls of the form
new("distributionH", x, p, m, s)
.
Antonio Irpino
Class distributionH
defines a histogram object
Irpino, A., Verde, R. (2015) Basic statistics for distributional symbolic variables: a new metric-based approach Advances in Data Analysis and Classification, DOI 10.1007/s11634-014-0176-4
meanH
computes the mean. stdH
computes the standard deviation.
#---- initialize a distributionH object mydist
# from a simple histogram
# ----------------------------
# | Bins | Prob | cdf |
# ----------------------------
# | [1,2) | 0.4 | 0.4 |
# | [2,3] | 0.6 | 1.0 |
# ----------------------------
# | Tot. | 1.0 | - |
# ----------------------------
mydist <- new("distributionH", c(1, 2, 3), c(0, 0.4, 1))
str(mydist)
# OUTPUT
# Formal class 'distributionH' [package "HistDAWass"] with 4 slots
# ..@ x: num [1:3] 1 2 3 the quantiles
# ..@ p: num [1:3] 0 0.4 1 the cdf
# ..@ m: num 2.1 the mean
# ..@ s: num 0.569 the standard deviation
# or using
mydist <- distributionH(x = c(1, 2, 3), p = c(0, 0.4, 1))
Run the code above in your browser using DataLab