Next: , Previous: , Up: Directory Index   [Contents][Index]


2.14 histograms

Function File: hgrm = createDeltaHist ( x0 )

Creates a histogram representing a delta function at a given value

Arguments

hgrm

delta function histogram

x0

location of delta function

Examples

createDeltaHist(1.23);
Function File: hgrm = createGaussianHist ( opt, val, … )

Creates a histogram representing a Gaussian PDF with given mean and standard deviation

Arguments

hgrm

Gaussian PDF histogram

Options

mean

mean of the Gaussian distribution

std

standard deviation

binsize

histogram bin-size (default = "std" / 10)

domain

constrain all samples to lie within this interval [min(domain), max(domain)]

Examples

hgrm = createGaussianHist(1.2, 3.4, "binsize", 0.1);
sert(abs(meanOfHist(hgrm) - 1.2) < 0.1)
sert(abs(sqrt(varianceOfHist(hgrm)) - 3.4) < 0.1)
Function File: cdf = cumulativeDistOfHist ( hgrm, x, [ k = 1 ] )

Evaluate the cumulative distribution function (c.d.f) of a histogram.

Arguments

hgrm

histogram object

x

argument to the c.d.f.

k

dimension over which to evaluate the c.d.f.

Examples

hgrm = Hist(2, {"lin", "dbin", 0.1}, {"lin", "dbin", 0.1});
hgrm = addDataToHist(hgrm, [octforge_normrnd(1.7, sqrt(2.3), 1e7, 1), rand(1e7, 1)]);
sert(abs(cumulativeDistOfHist(hgrm, 1.7 - sqrt(2.3), 1) - octforge_normcdf(-1)) < 0.005)
sert(abs(cumulativeDistOfHist(hgrm, 1.7, 1) - octforge_normcdf(0)) < 0.005)
sert(abs(cumulativeDistOfHist(hgrm, 1.7 + sqrt(2.3), 1) - octforge_normcdf(+1)) < 0.005)
sert(max(abs(cumulativeDistOfHist(hgrm, 0.33, 2)(50:end-50) - 0.33)) < 0.05)
sert(max(abs(cumulativeDistOfHist(hgrm, 0.77, 2)(50:end-50) - 0.77)) < 0.05)
Function File: mean = meanOfHist ( hgrm, [ k = 1 ] )

Returns the mean(s) of a histogram.

Arguments

hgrm

histogram object

k

dimension to calculate mean(s) over

Examples

hgrm = Hist(2, {"lin", "dbin", 0.01}, {"lin", "dbin", 0.1});
hgrm = addDataToHist(hgrm, [octforge_normrnd(1.7, 4.3, 1e6, 1), rand(1e6, 1)]);
sert(abs(meanOfHist(hgrm) - 1.7) < 5e-2)
Function File: mu = momentOfHist ( hgrm, sumdims, n, [ x0 = 0 ] )

Computes the moments of a histogram: Only moments for finite bins are returned.

Arguments

mu

integral over x{sumdims=sd} of p(x{sd(1)},...,x{sd(end)}) * (x{sd(1)}-x0{sd(1)})^n{sd(1)} * … * (x{sd(end)}-x0{sd(end)})^n{sd(end)} dx{sd(1)} ... dx{sd(end)}

hgrm

histogram object

sumdims

dimensions to be summed over

n

moment orders in each summed dimension

x0

bin offsets, must either be a scalar or match the sizes of the histogram dimensions *not* being summed over

Examples

hgrm = createGaussianHist(1.2, 3.4, "binsize", 0.1);
sert(momentOfHist(hgrm, 1, 0), 1.0, 1e-3)
sert(momentOfHist(hgrm, 1, 1), 1.2, 1e-3)
sert(momentOfHist(hgrm, 1, 2, 1.2), 3.4.^2, 1e-3)
sert(momentOfHist(hgrm, 1, 3, 1.2), 0.0, 1e-3)
Function File: plotHist ( hgrm, options, …, hgrm, options, … )
Function File: hh = plotHist ( … )

Plot a histogram as a stair graph

Arguments

hgrm

histogram object

options

options to pass to graphics function

hh

return graphics handles

plotHist()-specific options

stairs

if true [default], plot histogram as a stair-stepped graph; otherwise, plot a smooth line through bin centres

infbins

if true [default], plot stalks for counts in infinite bins

Examples

fig = figure("visible", "off");
hgrm = createGaussianHist(1.2, 3.4, "binsize", 0.1);
plotHist(hgrm, "k-");
plotHist(hgrm, "k-", "stairs", true);
plotHist(hgrm, "k-", "stairs", false);
close(fig);
Function File: printHistTable ( hgrm, opt, val, … )

Print the contents of a histogram object as an ASCII table.

Arguments

hgrm

histogram object

Options

dbins

width of bins to use in each dimension

pth

threshold to apply before printing

Examples

hgrm = Hist(2, {"lin", "dbin", 0.01}, {"lin", "dbin", 0.1});
hgrm = addDataToHist(hgrm, [octforge_normrnd(1.7, 4.3, 1e6, 1), rand(1e6, 1)]);
showHist(hgrm);
Function File: q.f. = quantileFuncOfHist ( hgrm, p, [ k = 1 ] )

Evaluate the quantile function (q.f.) of a histogram.

Arguments

hgrm

histogram object

p

quantile probability, in the range [0, 1]

k

dimension over which to evaluate the q.f.

Examples

hgrm = Hist(2, {"lin", "dbin", 0.1}, {"lin", "dbin", 0.1});
hgrm = addDataToHist(hgrm, [octforge_normrnd(1.7, sqrt(2.3), 1e7, 1), rand(1e7, 1)]);
sert(abs(quantileFuncOfHist(hgrm, octforge_normcdf(-1), 1) - (1.7 - sqrt(2.3))) < 0.01)
sert(abs(quantileFuncOfHist(hgrm, octforge_normcdf( 0), 1) - (1.7)) < 0.01)
sert(abs(quantileFuncOfHist(hgrm, octforge_normcdf(+1), 1) - (1.7 + sqrt(2.3))) < 0.01)
sert(max(abs(quantileFuncOfHist(hgrm, 0.33, 2)(50:end-50) - 0.33)) < 0.05)
sert(max(abs(quantileFuncOfHist(hgrm, 0.77, 2)(50:end-50) - 0.77)) < 0.05)
Function File: showHist ( hgrm )

Show the contents of a histogram object.

Arguments

hgrm

histogram object

Examples

hgrm = createGaussianHist(1.2, 3.4, "binsize", 0.1);
showHist(hgrm);
Function File: stdv = stdvOfHist ( hgrm, [ k = 1 ] )

Returns the standard deviation(s) of a histogram.

Arguments

hgrm

histogram object

k

dimension to calculate standard deviation(s) over

Examples

hgrm = Hist(2, {"lin", "dbin", 0.01}, {"lin", "dbin", 0.1});
hgrm = addDataToHist(hgrm, [octforge_normrnd(1.7, 4.3, 1e6, 1), rand(1e6, 1)]);
sert(abs(stdvOfHist(hgrm) - 4.3) < 5e-2)
sert(abs(stdvOfHist(hgrm) - sqrt(varianceOfHist(hgrm))) < 5e-2)
Function File: variance = varianceOfHist ( hgrm, [ k = 1 ] )

Returns the variance(s) of a histogram.

Arguments

hgrm

histogram object

k

dimension to calculate variance(s) over

Examples

hgrm = Hist(2, {"lin", "dbin", 0.01}, {"lin", "dbin", 0.1});
hgrm = addDataToHist(hgrm, [octforge_normrnd(1.7, sqrt(2.3), 1e7, 1), rand(1e7, 1)]);
sert(abs(meanOfHist(hgrm) - 1.7) < 5e-2)
sert(abs(varianceOfHist(hgrm) - 2.3) < 5e-2)

Next: , Previous: , Up: Directory Index   [Contents][Index]