Re: Fitting data
- To: mathgroup at smc.vnet.net
- Subject: [mg29594] Re: Fitting data
- From: Ignacio Rodriguez <ignacio at sgirmn.pluri.ucm.es>
- Date: Wed, 27 Jun 2001 05:12:28 -0400 (EDT)
- Organization: UCM
- References: <9h401r$4a6$1@smc.vnet.net> <9h8m2v$qsi$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Try with the package Statistics`NonlinearFit Richard wrote: > 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: [mg29594] 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 > > -- Ignacio Rodriguez Ramirez de Arellano Unidad de RMN Universidad Complutense Paseo Juan XXIII, 1 Madrid 28040, Spain Tel. 34-91-394-3288 Fax 34-91-394-3245 e-mail: ignacio at sgirmn.pluri.ucm.es