dMix: Mixture density

Description Usage Arguments Value See Also Examples

View source: R/0_Mix_utils.R

Description

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

Usage

1
dMix(x, obj, log = FALSE)

Arguments

x

vector of quantiles.

obj

object of class Mix.

log

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

Value

dMix(x) returns the numeric vector of probability values f(x), logged if log is TRUE.

See Also

Mix for the construction of Mix objects, rMix for random number generation (and construction of an rMix object) and plot.Mix which makes use of dMix.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# define 'Mix' object
normLocMix <- Mix("norm", 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)

anjaweigel/mixComp_package documentation built on Sept. 2, 2020, 3:55 p.m.