Re: Filtering data from numerical minimization
- To: mathgroup at smc.vnet.net
- Subject: [mg116800] Re: Filtering data from numerical minimization
- From: Sebastian <sebhofer at gmail.com>
- Date: Mon, 28 Feb 2011 05:02:14 -0500 (EST)
- References: <ijasgs$ned$1@smc.vnet.net>
On Feb 14, 10:26 am, Ray Koopman <koop... at sfu.ca> wrote: > Try increasing WorkingPrecision, AccuracyGoal, and PrecisionGoal. > Also, try a different Method. If that doesn't fix things, try using > better starting intervals. This may take two passes thru the list > 1...N. On the first pass, use your best a priori guess. On the > second pass, take the results from n-1 and n+1 on the previous pass > as the starting intervals for n. Take whichever results (pass 1 or 2) > give a lower fmin. Iterate (pass 3,4,...) until it stabilizes. The minimization is actually done in a similar way, as I use the optimal values from n-1 to generate initial values and constraints for n. It is funny that although I have these outliers, NMinimize finds its way back to a "good" value for the following points. Anyway... in the end I tackled my problem by defining a function which drops all points which violate monotonicity and applied it to my data by using FixedPoint. This may not be a general solution, but it worked reasonably well for this specific case. In case someone has a similar problem in the future, I included my code below. Cheers and thanks again for your help! Sebastian DefineFilter[cond_,options:OptionsPattern[]]:= Module[{ret}, ret=Switch[OptionValue[ReturnValue],"Position",True,_,False]; Return@With[{ret=ret},Function[t, Select[Table[If[i==1||i==Length@t||cond[t,i],If[ret,i,t[[i]]]],{= i, 1,Length@t}],#=!=Null&]]]; ]; Options[DefineFilter]={ReturnValue->"Value"}; Attributes[DefineFilter]={HoldAll}; (*usage example: only keep points which lie between the previous and following value*) filter=DefineFilter[(f /. #1[[#2 - 1]]) < (f /. #1[[#2]]) < (f /. #1[[#2 + 1]]) &]; datf=FixedPoint[cfilter, dat];