# LognormalMixAlt: Mixture of Two Lognormal Distributions (Alternative...

### Description

Density, distribution function, quantile function, and random generation for a mixture of two lognormal distribution with parameters `mean1`, `cv1`, `mean2`, `cv2`, and `p.mix`.

### Usage

 ```1 2 3 4 5 6 7 8``` ``` dlnormMixAlt(x, mean1 = exp(1/2), cv1 = sqrt(exp(1) - 1), mean2 = exp(1/2), cv2 = sqrt(exp(1) - 1), p.mix = 0.5) plnormMixAlt(q, mean1 = exp(1/2), cv1 = sqrt(exp(1) - 1), mean2 = exp(1/2), cv2 = sqrt(exp(1) - 1), p.mix = 0.5) qlnormMixAlt(p, mean1 = exp(1/2), cv1 = sqrt(exp(1) - 1), mean2 = exp(1/2), cv2 = sqrt(exp(1) - 1), p.mix = 0.5) rlnormMixAlt(n, mean1 = exp(1/2), cv1 = sqrt(exp(1) - 1), mean2 = exp(1/2), cv2 = sqrt(exp(1) - 1), p.mix = 0.5) ```

### Arguments

 `x` vector of quantiles. `q` vector of quantiles. `p` vector of probabilities between 0 and 1. `n` sample size. If `length(n)` is larger than 1, then `length(n)` random values are returned. `mean1` vector of means of the first lognormal random variable. The default is `meanlog1=sqrt(exp(1) - 1)`. `cv1` vector of coefficient of variations of the first lognormal random variable. The default is `sdlog1=sqrt(exp(1) - 1)`. `mean2` vector of means of the second lognormal random variable. The default is `mean2=sqrt(exp(1) - 1)`. `cv2` vector of coefficient of variations of the second lognormal random variable. The default is `sdlog2=sqrt(exp(1) - 1)`. `p.mix` vector of probabilities between 0 and 1 indicating the mixing proportion. For `rlnormMixAlt` this must be a single, non-missing number.

### Details

Let f(x; η, θ) denote the density of a lognormal random variable with parameters `mean=`η and `cv=`θ. The density, g, of a lognormal mixture random variable with parameters `mean1=`η_1, `cv1=`θ_1, `mean2=`η_2, `cv2=`θ_2, and `p.mix=`p is given by:

g(x; η_1, θ_1, η_2, θ_2, p) = (1 - p) f(x; η_1, θ_1) + p f(x; η_2, θ_2)

The default values for `mean1` and `cv1` correspond to a lognormal distribution with parameters `meanlog=0` and `sdlog=1`. Similarly for the default values of `mean2` and `cv2`.

### Value

`dlnormMixAlt` gives the density, `plnormMixAlt` gives the distribution function, `qlnormMixAlt` gives the quantile function, and `rlnormMixAlt` generates random deviates.

### Note

A lognormal mixture distribution is often used to model positive-valued data that appear to be “contaminated”; that is, most of the values appear to come from a single lognormal distribution, but a few “outliers” are apparent. In this case, the value of `mean2` would be larger than the value of `mean1`, and the mixing proportion `p.mix` would be fairly close to 0 (e.g., `p.mix=0.1`).

### Author(s)

Steven P. Millard (EnvStats@ProbStatInfo.com)

### References

Gilliom, R.J., and D.R. Helsel. (1986). Estimation of Distributional Parameters for Censored Trace Level Water Quality Data: 1. Estimation Techniques. Water Resources Research 22, 135-146.

Johnson, N. L., S. Kotz, and A.W. Kemp. (1992). Univariate Discrete Distributions. Second Edition. John Wiley and Sons, New York, pp.53-54, and Chapter 8.

Johnson, N. L., S. Kotz, and N. Balakrishnan. (1994). Continuous Univariate Distributions, Volume 1. Second Edition. John Wiley and Sons, New York.

LognormalAlt, LognormalMix, Lognormal, NormalMix, Probability Distributions and Random Numbers.

### Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31``` ``` # Density of a lognormal mixture with parameters mean=2, cv1=3, # mean2=4, cv2=5, p.mix=0.5, evaluated at 1.5: dlnormMixAlt(1.5, mean1 = 2, cv1 = 3, mean2 = 4, cv2 = 5, p.mix = 0.5) #[1] 0.1436045 #---------- # The cdf of a lognormal mixture with parameters mean=2, cv1=3, # mean2=4, cv2=5, p.mix=0.5, evaluated at 1.5: plnormMixAlt(1.5, mean1 = 2, cv1 = 3, mean2 = 4, cv2 = 5, p.mix = 0.5) #[1] 0.6778064 #---------- # The median of a lognormal mixture with parameters mean=2, cv1=3, # mean2=4, cv2=5, p.mix=0.5: qlnormMixAlt(0.5, 2, 3, 4, 5, 0.5) #[1] 0.6978355 #---------- # Random sample of 3 observations from a lognormal mixture with # parameters mean1=2, cv1=3, mean2=4, cv2=5, p.mix=0.5. # (Note: the call to set.seed simply allows you to reproduce this example.) set.seed(20) rlnormMixAlt(3, 2, 3, 4, 5, 0.5) #[1] 0.70672151 14.43226313 0.05521329 ```

Search within the EnvStats package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.