MathGroup Archive 2010

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

Search the Archive

Re: NonlinearModelFit ... please find me only integers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106355] Re: [mg106318] NonlinearModelFit ... please find me only integers
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 10 Jan 2010 03:29:43 -0500 (EST)
  • Reply-to: hanlonr at cox.net

You can try using Round in your model

data = {{0, 1}, {1, 0}, {3, 2},
   {5, 4}, {6, 4}, {7, 5}};

f[x_] = NonlinearModelFit[data,
   Log[a + b x^2], {a, b}, x] // Normal

Log[1.4263297975161129*x^2 + 1.5063204891556876]

f2[x_] = NonlinearModelFit[data,
   Log[a + Round[b] x^2], {a, b}, x] // Normal

Log[x^2 + 1.5806558441280811]

f3[x_] = NonlinearModelFit[data,
   Log[Round[a] + b x^2], {a, b}, x] // Normal

Log[1.444296658409274*x^2 + 1]

f4[x_] = NonlinearModelFit[data,
    Log[Round[a] + Round[b] x^2], {a, b}, x] //
   Normal // Quiet

Log[x^2 + 1]

Plot[Evaluate[Tooltip[#[x], #] & /@
   {f, f2, f3, f4}], {x, 0, 7},
 Epilog -> {Red, AbsolutePointSize[4],
   Point[data]},
 Frame -> True,
 Axes -> False,
 PlotRange ->
  {{-0.25, 7.25}, {-0.25, 5.25}},
 ImageSize -> 600]


Bob Hanlon

---- Ktota <nuktobi at gmail.com> wrote: 

=============
Hi there,

how can i tell NonlinearModelFit that a parameter it is supposed to
optimize should be only an Integer?

thank you

Konstantin



  • Prev by Date: Re: NonlinearModelFit ... please find me only integers
  • Next by Date: NonlinearModelFit and ParameterTable
  • Previous by thread: Re: NonlinearModelFit ... please find me only integers
  • Next by thread: Print Registration Marks