Re: fitting
- To: mathgroup at smc.vnet.net
- Subject: [mg104761] Re: fitting
- From: Ray Koopman <koopman at sfu.ca>
- Date: Sun, 8 Nov 2009 07:26:42 -0500 (EST)
- References: <hd3mt8$9sd$1@smc.vnet.net>
On Nov 7, 3:50 am, Vadim Zaliva <kroko... at gmail.com> wrote:
> Hi!
>
> I am very new to Mathematica and I am failing in trying to do
> something very simple.
> I am have the following data:
>
> x = {8, 36, 74, 96, 123, 152, 201, 269, 415, 460, 444, 579, 711,
> 731, 602, 364, 151};
>
> Which is a curve, similar to PDF function of Beta distribution:
>
> ListLinePlot[x]
>
> And I am trying to fit it to:
>
> PDF[BetaDistribution[\[Alpha], \[Beta]], x
>
> finding Alpha and Beta values.
>
> I will appreciate it somebody can give me a hint how to do this
> properly using FindFit or any other means. I am too embarrassed
> to post my modest attempts here, but trust me, I've spent few
> hours trying before posting :)
>
> Vadim
You haven't said what your 'x' represents or how it is supposed to
relate to the Beta distribution. If we take the values as the counts
in equal-width bins that cover [0,1], then we can get the sample mean
and variance using the midpoints of the bins as the x-values, and use
the method of moments to estimate 'a' and 'b', the parameters of the
distribution.
k = Length[f = {8, 36, 74, 96, 123, 152, 201, 269, 415, 460, 444,
579, 711, 731, 602, 364, 151}]
x = Range[1/2,k]/k; {n = Tr@f, N[m = f.x/n], N[v = f.x^2/n - m^2]}
Solve[{m == a/(a+b), v == m(1-m)/(1+a+b)}, {a,b}]//Flatten//N
17
{5416, 0.653065, 0.0391941}
{a -> 3.12214, b -> 1.65861}