| norm2d | R Documentation |
Evaluates the density of a bivariate normal distribution with mean vector
\mu = (\mu_x,\mu_y) and diagonal covariance matrix (independent components).
The density is the product of the two univariate normal densities:
f(x,y) = \phi(x;\mu_x,\sigma_x)\,\phi(y;\mu_y,\sigma_y).
norm2d(x, y, mu = c(0, 0), sd = c(1, 1), log = FALSE)
x |
Numeric vector of x-coordinate(s). |
y |
Numeric vector of y-coordinate(s). |
mu |
Numeric vector of length 2 giving |
sd |
Numeric vector of length 2 giving positive standard deviations |
log |
Logical; if |
Numeric vector of densities (or log-densities) with length determined by standard
recycling rules for x and y.
Mohammad Ghorbani mohammad.ghorbani@slu.se
Nafiseh Vafaei nafiseh.vafaei@slu.se
# Evaluate the density at the peak
norm2d(0.5, 0.5, mu = c(0.5, 0.5), sd = c(0.2, 0.2))
# Evaluate at multiple x values
norm2d(c(0.3, 0.7), 0.5, mu = c(0.5, 0.5), sd = c(0.2, 0.2))
# Visualize on a grid
x <- y <- seq(0, 1, length.out = 100)
f <- Vectorize(function(x, y) norm2d(x, y, mu = c(0.5, 0.5), sd = c(0.2, 0.2)))
z <- outer(x, y, f)
image(x, y, z, col = terrain.colors(50), main = "Bivariate Normal Intensity")
contour(x, y, z, add = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.