dMix: Mixture density

Description Usage Arguments Value See Also Examples

View source: R/0_Mix_utils.R

Description

Evaluation of the (log) density function of a mixture specified as a Mix object.

Usage

1
dMix(x, obj, log = FALSE)

Arguments

x

vector of quantiles.

obj

object of class Mix.

log

logical flag, if TRUE, probabilities/densities f are returned as log(f).

Value

dMix(x) returns a numeric vector of probability values f(x) and logarithm thereof if log is TRUE.

See Also

Mix for the construction of Mix objects, rMix for random number generation (and construction of rMix objects) and plot.Mix for plotting the densities computed using dMix.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# define 'Mix' object
normLocMix <- Mix("norm", discrete = FALSE, w = c(0.3, 0.4, 0.3), mean = c(10, 13, 17),
                  sd = c(1, 1, 1))

# evaluate density at points x
x <- seq(7, 20, length = 501)
dens <- dMix(x, normLocMix)
plot(x, dens, type = "l")

# compare to plot.Mix
plot(normLocMix)

mixComp documentation built on Feb. 25, 2021, 5:07 p.m.