MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Fitting data

  • To: mathgroup at smc.vnet.net
  • Subject: [mg29567] Re: Fitting data
  • From: "Richard" <wzn at jongnederland.nl>
  • Date: Mon, 25 Jun 2001 20:42:22 -0400 (EDT)
  • References: <9h401r$4a6$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

An normal distibution wasn't a good example.

What if I collected data from an experiment that I modeled by (for example):

u(t)= a1 * sin(a2*t) + a3*exp(a4^3).

How can I find a1, a2, a3 and a4 so that my function fits the data as good
as possible?

Thanx!!

----- Original Message -----
From: <BobHanlon at aol.com>
To: mathgroup at smc.vnet.net
Subject: [mg29567] Re: Fitting data


>
> 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: Unappropiate context in a package
  • Next by Date: Re: How do I really get rid of previous results?
  • Previous by thread: Re: Fitting data
  • Next by thread: Re: Fitting data