The core of the question is: Can I estimate the parameters of a gaussian mixture model (with EM or Dirichlet Process) from a mixture density directly, that is, without using data drawn from such mixture?

Long story

I have data that is a mixture density (spectroscopic data) that looks like this

The raw instrument data is binned, measuring how much light is reflected at various wavelengths.

Anyways, I want to decompose that density using a Gaussian Mixture Model GMM. For a tractable example, I simulate a mixture of two gaussians with the code below:

mu     = c(100, 200)
sd     = c(5, 10)
weight = c(0.25, 0.75)
xvec   = seq(0, 300)

mix_mat = mapply(function(x, y, z){
    dnorm(xvec, x, y)
}, mu, sd)

mix = mix_mat %*% weight 

mix_f = splinefun(mix)          # So the data is a real function

So, mix looks like a pretty simple mixture

Now, I've not been able to fit a gaussian mixture model directly to mix (or the function mix_f) in R. I end up having to draw a bunch of samples from the mixture and fit them instead. e.g.:


n      = 1000000
sampl  = runif(n, min(xvec), max(xvec))

s_prob = mix_f(sampl) + 1e-12  # Adding a small baseline so the 
                                # prob isn't zero anywhere
keep   = rbinom(n, 1, s_prob)
draws  = sampl[ which(keep == 1) ]

clust = mixtools::normalmixEM(draws, k = 2)

Which seems like a weird workaround. Is there a way I can avoid doing this?

  • $\begingroup$ What is the form of the density which you have, which you know (or assume (?)) to be a gaussian mixture, but for which you do not know the parameters? Does this describe your "use case"? The standard use case would be that you have some data and you use it to estimate the parameters of the GMM, correct? But that is not your (desired) situation? $\endgroup$ – Mark L. Stone Jul 31 '16 at 0:13
  • $\begingroup$ @MarkL.Stone It does describe my use case. In truth the data are binomial, how many photons are reflected from a surface at various wavelengths. (very fine scale), but it is conceptually a continuous function. $\endgroup$ – dudu Jul 31 '16 at 1:12
  • $\begingroup$ I still don't "get it". What is "wrong" with getting data, and using it to estimate the parameters of a GMM? Or is that you have an explicit formula for density function, with all parameters (numerical values) known, and you want to approximate it with a GMM whose parameter values you wish to determine? $\endgroup$ – Mark L. Stone Jul 31 '16 at 1:43
  • $\begingroup$ @MarkL.Stone Tx for responding. I haven's said there's anything wrong, just thought there may be a closed form solution. I end up having to draw ~10e6 points per data sample to keep noise manageable. Furthermore, drawing samples from the density seems like a hack anyways, since the 'data' isn't really the raw data... $\endgroup$ – dudu Jul 31 '16 at 2:08
  • $\begingroup$ I'm still trying to understand in what form the density is available to you. $\endgroup$ – Mark L. Stone Jul 31 '16 at 2:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.