Forget indenting. I like to just make my code all one line, with commands separated by ";".
A sufficient condition for a mixture of equal variance normals to be unimodal:
abs(mu1 - mu2) <= 2 * sigma * sqrt(1 + abs(log(p) - log(1 - p)) / 2) -- Everitt and Hand, "Finite Mixture Distribution", referencing Behboodian 1970. [Is this the right article?] Does estimation of the parameters become much harder when the threshold from bimodal to unimodal is crossed? What are similar conditions for a mixture with k components? For a mixture of k Ricians?
> sigma = 1
> # p = 0.5
> mu <- rep(c(0, 1), c(5000, 5000))
> y <- rnorm(10000, mean=mu, sd=sigma)
> hist(y) ##Appears to be unimodal
> mu <- rep(c(0, 3), c(5000, 5000))
> y <- rnorm(10000, mean=mu, sd=sigma)
> hist(y) ##Appears to be bimodal
> mu <- rep(c(0, 1), c(5000, 5000))
> y <- sqrt(rnorm(10000, mean=mu, sd=sigma)^2 + rnorm(10000, sd=sigma)^2)
> hist(y, nclass=100) ##Appears to be unimodal
> mu <- rep(c(0, 3), c(5000, 5000))
> y <- sqrt(rnorm(10000, mean=mu, sd=sigma)^2 + rnorm(10000, sd=sigma)^2)
> hist(y, nclass=100) ##Appears to be bimodal
The same pattern shows up using plot(density(...)) in place of hist(...).
No comments:
Post a Comment