Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9044

Re: Message using FindFit with LevenbergMarquardt Method

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Message using FindFit with LevenbergMarquardt Method
Date 2012-03-15 05:28 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jjruma$97b$1@smc.vnet.net> (permalink)
References <201203140541.AAA25797@smc.vnet.net>

Show all headers | View raw


Use Sqrt vice sqrt and e0 must also be listed as a parameter.

data = {{0., 0.425}, {60.6, 0.224}, {91.2, 0.1314},
   {119.4, 0.0716}, {150., 0.040}, {181.8, 0.0241}};

u = t*(a*Sqrt[e0])/2;

x = Tanh[t*(a*Sqrt[e0])/2];

Etac = e0*(1 - x^2) // Simplify;

fit = FindFit[data, Etac, {a, e0}, t, Method -> "LevenbergMarquardt"]

{a -> -1.9229190688022487*^23,
   e0 -> 0.42500000000000004}

This is a very bad fit. You need to provide starting estimates that
are "close" to the actual values.

fit = FindFit[data, Etac, {{a, 0.1}, {e0, 1}}, t,
  Method -> "LevenbergMarquardt"]

{a -> -0.0404696, e0 -> 0.420337}

Plot[Etac /. fit, {t, 0, 200},
 Epilog -> {Red, AbsolutePointSize[4], Point[data]}]


Bob Hanlon


On Wed, Mar 14, 2012 at 1:41 AM, geraldine oliveux
<geraldine.oliveux@free.fr> wrote:
> Hello,
>
> I'm a new user of Mathematica. I'm trying to fit data to a model in
> which I have one parameter. I try to determine this parameter by
> Levenberg-Marquardt Method.
> I wrote the following lines :
> data = {{0., 0.425}, {60.6, 0.224}, {91.2, 0.1314}, {119.4, 0.0716},
> {150., 0.040}, {181.8, 0.0241}}
> u = t*(a*sqrt[e0])/2
> x = Tanh[t*(a*sqrt[e0])/2]
> Etac = e0*(1 - x^2)
> fit = FindFit[data, Etac, a, t, Method -> "LevenbergMarquardt"]
>
> But it gives me the following message :
> FindFit::nrlnum: "The function value {0.,-0.224+0.425\ (1. -1.\
> Tanh[Times[<<2>>]]^2),-0.1314+0.425\ (1. -1.\
> Tanh[Times[<<2>>]]^2),-0.0716+0.425\ (1. -1.\
> Tanh[Times[<<2>>]]^2),-0.04+0.425\ (1. -1.\
> Tanh[Times[<<2>>]]^2),-0.0241+0.425\ (1. -1.\ Tanh[Times[<<2>>]]^2)}\
> \n is not a list of real numbers with dimensions {6} at {a} = {1.}. "
>
> What does it mean ? I think there is something I don't do well, and
> that it concerns the data declaration.
> Thank you in advance for your help,
> Best regards,
> G=E9raldine
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Message using FindFit with LevenbergMarquardt Method Bob Hanlon <hanlonr357@gmail.com> - 2012-03-15 05:28 +0000

csiph-web