Re: Fitting data

• To: mathgroup at smc.vnet.net
• Subject: [mg29547] Re: [mg29535] Fitting data
• From: BobHanlon at aol.com
• Date: Sun, 24 Jun 2001 02:01:00 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```In a message dated 2001/6/23 2:01:40 AM, wzn at jongnederland.nl writes:

>How can I fit an function to data in mathematica? For example: in an
>experiment I collect data with a normal distrubution. I want to fit a normal
>curve to this data, with unknown mean and variance. Can I do this with
>the
>mean-squares-method or do I need an iterative algorithm or something like
>that?

Fitting a distribution is not the same thing as fitting a function.

For a normal distribution it is quite straightforward.  The maximum
likelihood
estimation of the mean of the distribution is Mean[data]

The maximum likelihood estimation of the standard deviation of the
distribution is StandardDeviationMLE[data]

Needs["Statistics`NormalDistribution`"];
Needs["Graphics`Colors`"];

Let the "unknown" mean and standard deviation be

{m, s} = {5*Random[], 2*Random[]}

{1.3655769021908775, 0.2746217115738358}

Taking a random sampling from this distribution

data = RandomArray[NormalDistribution[m, s], {100}];

The parameter estimates are then

{me, se} = {Mean[data], StandardDeviationMLE[data]}

{1.3879937672329135, 0.28629145363687175}

Comparing the estimate of the distribution with the actual distribution

Plot[{PDF[NormalDistribution[m, s], x], PDF[NormalDistribution[me, se], x],
CDF[NormalDistribution[m, s], x],
CDF[NormalDistribution[me, se], x]}, {x, m-2s, m+2s},
PlotStyle -> {Blue, Red}, ImageSize -> 400];

Bob Hanlon
Chantilly, VA  USA

```

• Prev by Date: Re: Encode
• Next by Date: Re: Equality question
• Previous by thread: Fitting data
• Next by thread: Re: Fitting data