MathGroup Archive 2012

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

Search the Archive

Re: Removing Outliers from List


list = {24, 24, 3, 2, 1, 1, 1, 1};

Module[{clusters = FindClusters[list], len},
 len = Max[Length /@ clusters];
 Select[clusters, Length[#] == len &][[1]]]

{3, 2, 1, 1, 1, 1}


Bob Hanlon


On Tue, Aug 14, 2012 at 4:20 AM, Murta <rodrigomurtax at gmail.com> wrote:
> Hi All
>
>     Some simple idea on how to remove the outliers from a list like this?:
>
>     l={24, 24, 3, 2, 1, 1, 1, 1}
>
>     to get this:
>
>     l={3, 2, 1, 1, 1, 1}
>
> I have one complicated one that need a lower sigma parameter to work:
> ------------------------------------------------
> l={24, 24, 3, 2, 1, 1, 1, 1}
>
> removeNormalOutliers[data_,\[Alpha]_:2.09]:=Block[{removeSub},
>
>         removeSub[dataSub_]:=Module[{\[Sigma],\[Mu],return},
>                 If[Length[dataSub]>1,\[Mu]=N@Mean[dataSub];
>                 \[Sigma]=N@StandardDeviation[dataSub];
>                 return=Select[dataSub,#<=\[Mu]+\[Alpha] \[Sigma]&],dataSub]
>         ];
>         FixedPoint[removeSub,data,20]
> ]
>
> removeNormalOutliers[l, 1]
> ------------------------------------------------
>
> Some better/simple idea?
> tks in advance
> Murta
>



  • Prev by Date: Re: Find Position of many elements in a large list.
  • Next by Date: V8 slow like a snail
  • Previous by thread: Removing Outliers from List
  • Next by thread: Re: Removing Outliers from List