50% off | Unlimited Data & AI Learning
Get 50% off unlimited learning

nor1mix (version 1.1-3)

r.norMix: Ratio of Normal Mixture to Corresponding Normal

Description

Compute $r(x) = f(x)/ f0(x)$ where $f()$ is a normal mixture density and $f0$ the normal density with the same mean and variance as $f$.

Usage

r.norMix(obj, x = NULL, xlim = NULL, n = 511, xy.return = TRUE)

Arguments

obj
an object of class norMix.
x
numeric vector with abscissa values where to evaluate the density. Default is constructed from n (and xlim if specified).
xlim
range of abscissa values, used if x == NULL. By default, xlim taken as mean plus/minus 3 standard deviations of the normal mixture.
n
number of abscissa values to generate if x is not specified.
xy.return
logical indicating if the result should be a list or just a numeric vector, see below.

Value

  • It depends on xy.return. If it's false, a numeric vector of the same length as x, if true (as per default), a list that can be plotted, with components
  • xabscissa values corresponding to argument x.
  • ycorresponding values $r(x)$.
  • f0values of the moment matching normal density $f0(x)$.

Examples

Run this code
d3 <- norMix(m = 5*(0:2), w = c(0.6, 0.3, 0.1))
  plot(d3)
  rd3 <- r.norMix(d3)
  str(rd3)
  stopifnot(rd3 $ y  == r.norMix(d3, xy.ret = FALSE))
  par(new = TRUE)
  plot(rd3, type = "l", col = 3, axes = FALSE, xlab = "", ylab="")
  axis(4, col.axis=3)

Run the code above in your browser using DataLab