| utils-density2d | R Documentation |
Kernel density estimator and histogram counter for bivariate distributions
density2d(x, y = NULL, n = 20, h = NULL, limits = c(range(x), range(y)))
hist2d(x, y = NULL, n = c(20, 20))
x, y |
two vectors of coordinates of data. If |
n |
n - an integer specifying the number of grid points in each
direction. The default value is 20. |
h |
a vector of bandwidths for |
limits |
the limits of the rectangle covered by the grid. |
density2d and hist2d
return a list with three elements $x, $y, and
$z. x and y are vectors spanning the two
dimensional grid and z the corresponding matrix. The
output can directly serve as input to the plotting functions
image, contour and persp.
W.N. Venables and B.D. Ripley for the underlying kde2d function,
Gregory R. Warnes for the underlying hist2d function,
Diethelm Wuertz for the Rmetrics R-port.
Azzalini A., (2004); The sn Package; R Reference Guide available from www.r-project.org.
Venables W.N., Ripley B.D., (2002); Modern Applied Statistics with S, Fourth Edition, Springer.
Warnes G.R., (2004); The gregmisc Package; R Reference Guide available from www.r-project.org.
## hist2d -
# Normal Random Numbers:
set.seed(4711)
X <- rnorm2d(40000)
# 2D Histogram Plot:
Z <- hist2d(X)
image(Z)
contour(Z, add=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.