Empirical Estimation
Histograms
The Histogram
type represents data that has been tabulated into intervals (known as bins) along the real line, or in higher dimensions, over the real plane.
Histograms can be fitted to data using the fit
method.
StatsBase.fit
— Method.fit(Histogram, data[, weight][, edges]; closed=:left, nbins)
Fit a histogram to data
.
Arguments
data
: either a vector (for a 1-dimensional histogram), or a tuple of vectors of equal length (for an n-dimensional histogram).weight
: an optionalAbstractWeights
(of the same length as the data vectors), denoting the weight each observation contributes to the bin. If no weight vector is supplied, each observation has weight 1.edges
: a vector (typically anAbstractRange
object), or tuple of vectors, that gives the edges of the bins along each dimension. If no edges are provided, these are determined from the data.
Keyword arguments
closed
: if:left
(the default), the bin intervals are left-closed [a,b); if:right
, intervals are right-closed (a,b].nbins
: if noedges
argument is supplied, the approximate number of bins to use along each dimension (can be either a single integer, or a tuple of integers).
Examples
# Univariate
h = fit(Histogram, rand(100))
h = fit(Histogram, rand(100), 0:0.1:1.0)
h = fit(Histogram, rand(100), nbins=10)
h = fit(Histogram, rand(100), weights(rand(100)), 0:0.1:1.0)
h = fit(Histogram, [20], 0:20:100)
h = fit(Histogram, [20], 0:20:100, closed=:right)
# Multivariate
h = fit(Histogram, (rand(100),rand(100)))
h = fit(Histogram, (rand(100),rand(100)),nbins=10)
Additional methods
Base.merge!
— Function.merge!(target::Histogram, others::Histogram...)
Update histogram target
by merging it with the histograms others
. See merge(histogram::Histogram, others::Histogram...)
for details.
Base.merge
— Function.merge(h::Histogram, others::Histogram...)
Construct a new histogram by merging h
with others
. All histograms must have the same binning, shape of weights and properties (closed
and isdensity
). The weights of all histograms are summed up for each bin, the weights of the resulting histogram will have the same type as those of h
.
Missing docstring for norm
. Check Documenter's build log for details.
Missing docstring for normalize
. Check Documenter's build log for details.
Missing docstring for normalize!
. Check Documenter's build log for details.
Base.zero
— Function.zero(h::Histogram)
Create a new histogram with the same binning, type and shape of weights and the same properties (closed
and isdensity
) as h
, with all weights set to zero.
Empirical Cumulative Distribution Function
StatsBase.ecdf
— Function.ecdf(X)
Return an empirical cumulative distribution function (ECDF) based on a vector of samples given in X
.
Note: this function that returns a callable composite type, which can then be applied to evaluate CDF values on other samples.
extrema
, minimum
, and maximum
are supported to for obtaining the range over which function is inside the interval $(0,1)$; the function is defined for the whole real line.