I am quite new to statistics, so please forgive me for using probably the wrong vocabulary.
I have some data that looks (to me) like a gaussian when plotted.
The data is an extract from a jpeg image. It's a vertical line taken from the image, and only the Red data is used (from RGB).
Here is the full data (27 data points):
> r
[1] 0.003921569 0.031372549 0.023529412 0.015686275 0.003921569 0.027450980
[7] 0.003921569 0.015686275 0.031372549 0.105882353 0.305882353 0.490196078
[13] 0.560784314 0.615686275 0.592156863 0.505882353 0.364705882 0.227450980
[19] 0.050980392 0.031372549 0.019607843 0.054901961 0.031372549 0.015686275
[25] 0.027450980 0.003921569 0.011764706
> dput(r)
c(0.00392156862745098, 0.0313725490196078, 0.0235294117647059,
0.0156862745098039, 0.00392156862745098, 0.0274509803921569,
0.00392156862745098, 0.0156862745098039, 0.0313725490196078,
0.105882352941176, 0.305882352941176, 0.490196078431373, 0.56078431372549,
0.615686274509804, 0.592156862745098, 0.505882352941176, 0.364705882352941,
0.227450980392157, 0.0509803921568627, 0.0313725490196078, 0.0196078431372549,
0.0549019607843137, 0.0313725490196078, 0.0156862745098039, 0.0274509803921569,
0.00392156862745098, 0.0117647058823529)
plot(r)
I would like to find a gaussian that is as close as possible to the plot/data.
I tried with normalmixEM from the R package mixtools.
> fit = normalmixEM(r)
but this seems to try to fit to a mix of two gaussian by default.
I tried to specify that there is only one gaussian using the parameter k:
> fit = normalmixEM(r, k = 1)
Error in normalmix.init(x = x, lambda = lambda, mu = mu, s = sigma, k = k, :
arbmean and arbvar cannot both be FALSE
How can I fit the data?
dput(r)
to generate a string that is easily copy'n'pasteable. Now we have to enter the data in r manually... $\endgroup$R
solution for a discrete variable like yourIndex
appears at stats.stackexchange.com/a/43004/919; anR
solution for a continuous variable is at stats.stackexchange.com/questions/70153/…; and an Excel solution is at stats.stackexchange.com/a/11563/919. $\endgroup$