Matching density with normal and uniform distributions I will have data not too dissimilar from this:

I'd like to match the density with a set of (truncated) normal distributions and one underlying uniform distribution. I know where the spikes are, these are my means for the normals, but I don't know what the variances are. Sort of like this decomposition of a similar dataset.

So my only unknowns are variances of $k$ normals ($k$ is known) and the density of the uniform distribution. As for the truncation: Two of the means are 0 and 100 (boundaries), so I will only use half of the bell curve in each case. Edit: I've just realized that not all the normals will represent the same amount of data, so some truncation and rescaling will be in order.
I suppose I'll have to do a grid search and compare the deviations from the density in each iteration -- but I don't really know where to start. Or if there's a package that would do that for me.
I work in Stata and R, so any tips on on how to do it in either of the two is fine (preferably for the former). I have stumbled upon the fmm package (finite mixture models), but I'm not sure that fits (excuse the pun).
 A: I have an almost complete solution for both Stata and R. (It lacks the truncation and the uniform distribution.)
Stata
I used the fmm package (finite mixture models) that fits various distributions and their mixtures to data. It estimates the mean, variance and proportion of each distribution within the data. So it is good on its own, but constraints can be defined.
Use constraint define 1 [component1]_cons=35 and constraint define 2 [component2]_cons=22 to define fixed means for two distributions and estimate the variances and proportions using
fmm variable, components(2) mixtureof(normal) constraints(1,2)
And increase the components option if you want to fit more.
R
There are at least two packages, the "automatic" mclust that takes no parameters and presumably compares AIC to make the best fit. And FlexMix with a little more polish.
library(mclust)
library(flexmix)
x <- as.vector(t(read.table(...)))
mc <- Mclust(x)
fl <- FlexMix(x~1,k=4)

With FlexMix you specify the number of components as k. Both give you the means, variances, and proportions.
Sources:


*

*Slides for fmm with the algebra behind it

*Code for both R examples - includes plotting, overlaying histograms and other fancy bits

