ecdfhist
statistics: [n, c] = ecdfhist (f, x)
statistics: [n, c] = ecdfhist (f, x, m)
statistics: [n, c] = ecdfhist (f, x, centers)
statistics: ecdfhist (…)
statistics: ecdfhist (ax, …)
Create a histogram from the output of ecdf.
[n, c] = ecdfhist (f, x) takes the empirical
cumulative distribution function f evaluated at the points x, as
computed by ecdf, and returns the heights n of histogram bars
for 10 equally spaced bins together with their centers c. Unlike a
count histogram, the bar heights are normalized so that the area of the
histogram is equal to 1, giving an estimate of the probability density
function.
[n, c] = ecdfhist (f, x, m) uses m
equally spaced bins.
[n, c] = ecdfhist (f, x, centers) uses
bins with the specified centers, given as a vector of monotonically
increasing values.
ecdfhist (…) without output arguments plots the histogram.
ecdfhist (ax, …) plots into the axes ax instead of
the current axes.
The probability mass assigned to each bin is the sum of the increments of the
empirical cdf, diff (f), over the points x that fall
closest to the corresponding bin center; ties are assigned to the lower
center. Each bar height is that mass divided by the bin width.
See also: ecdf, cdfplot, hist, histogram
Source Code: ecdfhist
Histogram (density estimate) from the empirical cdf of a random sample.
x = randn (100, 1);
[f, xx] = ecdf (x);
ecdfhist (f, xx);
title ("ecdfhist of a standard normal sample");
Compare the empirical density with a finer set of bins.
x = exprnd (2, 200, 1);
[f, xx] = ecdf (x);
ecdfhist (f, xx, 20);
title ("ecdfhist of an exponential sample (20 bins)");