Re: Filtering data from numerical minimization
- To: mathgroup at smc.vnet.net
- Subject: [mg116862] Re: Filtering data from numerical minimization
- From: Sebastian <sebhofer at gmail.com>
- Date: Wed, 2 Mar 2011 04:37:36 -0500 (EST)
- References: <ijasgs$ned$1@smc.vnet.net> <ikfv4k$f7v$1@smc.vnet.net> <ikihdd$7of$1@smc.vnet.net>
Sorry for that, there is a typo in the code above. Also, I should have included a sample of my data. For completeness: 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}; filter1 = DefineFilter[(f /. #1[[#2 - 1]]) < (f /. #1[[#2]]) < (f /. #1[[#2 + 1]]) &]; noise = RandomReal[NormalDistribution[0, .75], m = 30]; data = Table[{x -> n, f -> n + %[[n]]}, {n, 1, m}]; fdata = {x, f} /. filter1[data]; ListPlot[fdata] I hope it works this time. Anyway, you are of course right and my code does drop points which could be kept, I'm aware of that. My data is not to big (a few hundreds of points at most) so the brute force method might actually be feasible. I will definitely try it out at some point and tell you the results. It may be a while though, as I have more pressing problems to work on at the moment. Best regards, Sebastian