BivNormal function

Bivariate normal distribution

Bivariate normal distribution

Density, distribution function and random generation for the bivariate normal distribution.

dbvnorm( x, y = NULL, mean1 = 0, mean2 = mean1, sd1 = 1, sd2 = sd1, cor = 0, log = FALSE ) rbvnorm(n, mean1 = 0, mean2 = mean1, sd1 = 1, sd2 = sd1, cor = 0)

Arguments

  • x, y: vectors of quantiles; alternatively x may be a two-column matrix (or data.frame) and y may be omitted.
  • mean1, mean2: vectors of means.
  • sd1, sd2: vectors of standard deviations.
  • cor: vector of correlations (-1 < cor < 1).
  • log: logical; if TRUE, probabilities p are given as log(p).
  • n: number of observations. If length(n) > 1, the length is taken to be the number required.

Details

Probability density function

f(x)=12π1ρ2σ1σ2exp{12(1ρ2)[(x1μ1σ1)22ρ(x1μ1σ1)(x2μ2σ2)+(x2μ2σ2)2]}f(x)=1/(2πsqrt(1ρ2)σ1σ2)exp((1/(2(1ρ2)(((x1μ1)/σ1)22ρ((x1μ1)/σ2)((x2μ2)/σ2)((x2μ2)/σ2)2)))) f(x) = \frac{1}{2\pi\sqrt{1-\rho^2}\sigma_1\sigma_2}\exp\left\{-\frac{1}{2(1-\rho^2)} \left[\left(\frac{x_1 - \mu_1}{\sigma_1}\right)^2 -2\rho \left(\frac{x_1 - \mu_1}{\sigma_1}\right) \left(\frac{x_2 - \mu_2}{\sigma_2}\right) +\left(\frac{x_2 - \mu_2}{\sigma_2}\right)^2\right]\right\}f(x) = 1/(2*\pi*sqrt(1-\rho^2)*\sigma1*\sigma2) * exp(-(1/(2*(1-\rho^2)*(((x1-\mu1)/\sigma1)^2 - 2*\rho*((x1-\mu1)/\sigma2)*((x2-\mu2)/\sigma2) *((x2-\mu2)/\sigma2)^2))))

Examples

y <- x <- seq(-4, 4, by = 0.25) z <- outer(x, y, function(x, y) dbvnorm(x, y, cor = -0.75)) persp(x, y, z) y <- x <- seq(-4, 4, by = 0.25) z <- outer(x, y, function(x, y) dbvnorm(x, y, cor = -0.25)) persp(x, y, z)

References

Krishnamoorthy, K. (2006). Handbook of Statistical Distributions with Applications. Chapman & Hall/CRC

Mukhopadhyay, N. (2000). Probability and statistical inference. Chapman & Hall/CRC

See Also

Normal

  • Maintainer: Tymoteusz Wolodzko
  • License: GPL-2
  • Last published: 2023-11-30