MixNormal: Probability functions of mixture of normal distributions

dMixNormalR Documentation

Probability functions of mixture of normal distributions

Description

Density function, cumulative distribution function and random generation for the mixture of normal distributions

Usage

dMixNormal(x, mean, sd, probs)

pMixNormal(q, mean, sd, probs, lower.tail = TRUE)

rMixNormal(n, mean, sd, probs)

Arguments

x

the quantile for which density will be determined

mean

the vector of means of mixed normal distributions

sd

the vector of standard deviations of mixed normal distributions

probs

the vector of normalized probability weight of mixed normal distributions

q

the quantile for which cumulative distribution will be determined

lower.tail

logical, if TRUE (default), probability of X being smaller than or equal to q is returned. If false, the probability of being greater is returned.

n

the number of random values to return

Value

dMixNormal returns the probability density

pMixNormal returns the cumulative distribution

rMixNormal returns a vector of random numbers following the specified distribution

Examples

# generate some random numbers from the mixture of two normal distributions
# with equal variance and weight but different means
norm.mix = rMixNorm(n=1e3,mean=c(-1,1),sd=c(1,1),probs=c(0.5,0.5))

# test the empirical distribution against the theoretical one
ks.test(norm.mix,pMixNormal,mean=c(-1,1),sd=c(1,1),probs=c(0.5,0.5))

wu-lab-uva/RasperGade documentation built on June 24, 2022, 2:47 p.m.