Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1996

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

Search the Archive

Boundaries in Nonlinear Fittings

  • To: mathgroup at smc.vnet.net
  • Subject: [mg3925] Boundaries in Nonlinear Fittings
  • From: Christian MONTANARI <cm at ee.port.ac.uk>
  • Date: Fri, 10 May 1996 03:28:52 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

Here is a patch to NonlinearFit.m which allows to "bounce" on the 
boundaries of your fit.
and... non buggy weigthing factors!

It worked for the fitting of my data.

Christian

PS:Dr. Wolfram might get me a medail?

Address: University of Portsmouth,
	 Department of Electrical and Electronic Engineering,
         Microwave, Telecommunications and Signal Processing Research Group,
         Anglesea Building,    		        Phone: +44 (0)1705 842543
         Anglesea Road,				Fax:   +44 (0)1705 295336
         Portsmouth,P01 3DJ,England.		Email: cm at ee.port.ac.uk


23d22
< 	Version 1.2, Sep 1994 C. Montanari !...
41c40
< Print["chris modifs..in NonlinearFit.00."];
---
> 
59,62d57
< BoundsStop::usage =
< "BoundsStop is an option for NonlinearFit. If True, the fit will stop
< when the range limits of the parameters are encountered."
< 
83,84c78
< 	PrecisionGoal -> 3,
< 	BoundsStop -> False};
---
> 	PrecisionGoal -> 3};
170c164
< 			Map[If[Head[#] === List, Last[Last[#]], 1]&,
---
> 			Map[If[Head[#] === List, Last[#], 1]&,
200c194
< 			fmopts,out,start,precgoal,response,s,bounds},
---
> 			fmopts,out,start,precgoal,response,s},
202c196
< 		{maxits,method,progress,weights,workprec,accgoal,precgoal,bounds} =
---
> 		{maxits,method,progress,weights,workprec,accgoal,precgoal} =
204,205c198,199
< 				WorkingPrecision, AccuracyGoal, PrecisionGoal,
< 				BoundsStop}/.{opts}/.Options[NonlinearFit];
---
> 				WorkingPrecision, AccuracyGoal, PrecisionGoal}/.
> 			{opts}/.Options[NonlinearFit];
224c218
< 			weights = Table[1,{#1},{#2}]& @@ Dimensions[response];
---
> 			weights = Table[1,{#1},{#2}]& @@ Dimensions[response]
241c235
< 					{x,{s},min,max},
---
> 					{x,s,min,max},
279d272
< 		bounds=TrueQ[bounds];
288c281
< 				maxrng,progress,bounds,maxits,workprec,precgoal,accgoal,
---
> 				maxrng, progress, maxits, workprec, precgoal, accgoal,
305c298
< 		parameters_,start_,minr_,maxr_,prog_,bounds_,mi_,wp_,pg_,ag_,
---
> 		parameters_, start_, minr_, maxr_, prog_, mi_, wp_, pg_, ag_,
340c333
< 		params_,start_,minr_,maxr_,progress_,bounds_,maxits_, 
---
> 		params_, start_, minr_, maxr_, progress_, maxits_, 
343,344c336,337
< 			nweights = N[weights, wp], guess = N[start, wp], guessy,
< 			nminr = N[minr, wp], nmaxr = N[maxr, wp], lambda=1/100,
---
> 			nweights = N[weights, wp], guess = N[start, wp], 
> 			nminr = N[minr, wp], nmaxr = N[maxr, wp], lambda = 1/1000,
349,353d341
< 
< 		If[!bounds,
< 			guess=Map[Max,Transpose[{guess,nminr}]];
< 			guess=Map[Min,Transpose[{guess,nmaxr}]]];
< 
369,370c357
< 				(rngflag = !bounds ||
< 					(And @@ Thread[N[nminr < guess < nmaxr,wp]])),
---
> 				(rngflag = And @@ Thread[N[nminr < guess < nmaxr,wp]]),
378,383c365
< 			guessy=guess+deltaguess;
< 			If[!bounds,
< 				guessy=Map[Max,Transpose[{guessy,nminr}]];
< 				guessy=Map[Min,Transpose[{guessy,nmaxr}]]];
< (*			Print[bounds,rngflag,guessy,nminr,nmaxr];*)
< 			newvals = vals @@ guessy;
---
> 			newvals = vals @@ (guess + deltaguess);
385d366
< 			
392,394c373,375
< 				guess = guessy;
< 				tmpchi = newchi;
< 				{alpha, beta} = calcstep[response, nweights,
---
> 					guess = guess + deltaguess;
> 					tmpchi = newchi;
> 					{alpha, beta} = calcstep[response, nweights,

--2009596274-851401618-830962609=:11098
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xUcmFuc3Bvc2Vbe2d1ZXNzeSxubWlucn1d
XTsNCjwgCQkJCWd1ZXNzeT1NYXBbTWluLFRyYW5zcG9zZVt7Z3Vlc3N5LG5t
YXhyfV1dXTsNCjwgKCoJCQlQcmludFtib3VuZHMscm5nZmxhZyxndWVzc3ks
bm1pbnIsbm1heHJdOyopDQo8IAkJCW5ld3ZhbHMgPSB2YWxzIEBAIGd1ZXNz
eTsNCi0tLQ0KPiAJCQluZXd2YWxzID0gdmFscyBAQCAoZ3Vlc3MgKyBkZWx0
YWd1ZXNzKTsNCjM4NWQzNjYNCjwgCQkJDQozOTIsMzk0YzM3MywzNzUNCjwg
CQkJCWd1ZXNzID0gZ3Vlc3N5Ow0KPCAJCQkJdG1wY2hpID0gbmV3Y2hpOw0K
PCAJCQkJe2FscGhhLCBiZXRhfSA9IGNhbGNzdGVwW3Jlc3BvbnNlLCBud2Vp
Z2h0cywNCi0tLQ0KPiAJCQkJCWd1ZXNzID0gZ3Vlc3MgKyBkZWx0YWd1ZXNz
Ow0KPiAJCQkJCXRtcGNoaSA9IG5ld2NoaTsNCj4gCQkJCQl7YWxwaGEsIGJl
dGF9ID0gY2FsY3N0ZXBbcmVzcG9uc2UsIG53ZWlnaHRzLA0K
--2009596274-851401618-830962609=:11098--

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: MultipleListPlot
  • Next by Date: Installation
  • Previous by thread: MultipleListPlot
  • Next by thread: Installation