MathGroup Archive 2007

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

Search the Archive

Re: Using FindFit with constraints ??


I can't read your code -- what the heck is =CF=89? -- but this code 
works  

just fine in version 6:

model = a Cos[c t];
data = Table[{t, Cos[2.1 t]}, {t, 0, 10, .25}] + RandomReal[.1, 41];
fit = FindFit[data, {model, {a > 0, 1 < c < 2}}, {a, c}, t]

{a -> 0.867956, c -> 2.}

It doesn't work in version 5.2, because (1) RandomReal isn't defined and =

(2) constraints (like {a > 0, 1 < c < 2}) are not supported in the older =

version.

Bobby

On Tue, 08 May 2007 04:45:28 -0500, Alex <axel.kowald at rub.de> wrote:

> Hello everybody,
>
> I saw at http://reference.wolfram.com/mathematica/ref/FindFit.html
> that FindFit can be used with constraints for the parameters. However
> when I try the example with Mathematica 5.2 I get an error.
>
> model = a Cos[=CF=89 t];
> data = Table[{t, Cos[2.1 t]}, {t, 0, 10, .25}] + RandomReal[.1, 41];
> fit = FindFit[data, {model, {a > 0, 1 < =CF=89 < 2}}, {a, =CF==
89}, t]
>
> =>
> FindFit::nlnum: The function value {-1. + Cos[RandomReal[0.1, 41.]] -
> \
> 1=2E\RandomReal[0.1, 41.], \[LeftSkeleton]9\[RightSkeleton], \
> [LeftSkeleton]113\
> \[RightSkeleton]} is not a list of numbers with dimensions {123} at
> {a, =CF=89} = \
> {1, 1}.
>
>
> What am I doing wrong ??
>
> Alex
>
>
>



-- =

DrMajorBob at bigfoot.com


  • Prev by Date: Simplify by Recurrence Relations
  • Next by Date: Re: question
  • Previous by thread: Re: Using FindFit with constraints ??
  • Next by thread: Re: Using FindFit with constraints ??