Learn R Programming

mixComp (version 0.1-2)

dMix: Mixture density

Description

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

Usage

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

Run this code
# NOT RUN {
# 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)

# }

Run the code above in your browser using DataLab