Learn R Programming

Sim.DiffProc (version 2.5)

hist_meth: Histograms of Random Variable X

Description

The generic function hist_meth computes a histogram of the given data values.

Usage

hist_meth(X, Breaks, Prob = c("TRUE", "FALSE"))

Arguments

X
a numeric vector of the observed values.
Breaks
one of: o a vector giving the breakpoints between histogram cells. o a single number giving the number of cells for the histogram. o a function to compute the number of cells. o Breaks = c('scott','Sturges','FD') or manual.
Prob
logical; if TRUE, the histogram graphic is a representation of frequencies, the counts component of the result; if FALSE, probability densities, component density, are plotted (so that the histogram has a total area of one). Defaults to TRUE if and only i

Value

  • plot.histogram for the random variable X.

Details

The definition of histogram differs by source (with country-specific biases). R's default with equi-spaced breaks (also the default) is to plot the counts in the cells defined by breaks. Thus the height of a rectangle is proportional to the number of points falling into the cell, as is the area provided the breaks are equally-spaced.

See Also

Kern_meth Kernel Density,fctrep_Meth Empirical Distribution.

Examples

Run this code
X <- rexp(1000,2)
 X11()
 hist_meth(X, Breaks='scott', Prob ="TRUE")
 curve(dexp(x, 2), col = 2, lwd = 2, add = TRUE)
 X11()
 hist_meth(X, Breaks='FD', Prob ="TRUE")
 curve(dgamma(x,1, 2), col = 2, lwd = 2, add = TRUE)
 X11()
 hist_meth(X, Breaks=100, Prob ="TRUE")
 curve(dweibull(x,1, 0.5),col=2, lwd = 2, add = TRUE)

Run the code above in your browser using DataLab