I created a tester class to verify that our Grubbs' test. I use Flash CS4 as my coding environment, so this class might look a tad different for you Flex people out there.

package {
    import flash.display.*
    public class Main extends MovieClip{
        public function Main():void {
            var dataSample:Array = [30, 171, 184, 201, 212,
                                    250, 265, 270, 272, 289,
                                    305, 306, 322, 322, 336,
                                    346, 351, 370, 390, 404,
                                    409, 411, 436, 437, 439];
           
            //var outlier:int = Grubbs.findOutlier(dataSample, Grubbs.T_950);
            trace("Outlier?: "+Grubbs.findOutlier(dataSample, Grubbs.T_950));
           
        }
    }
}


Here you can see that I've created a sample array of 25 data entries. Looking over the entries, we can probably guess that the value '30' is an outlier. But do what degree of certainty? Let's find out!

Every time Main() is called, the trace function will make a call to Grubbs.findOutlier(), and then print the result to the console. For my first test I will be using the array of t-distribution values at 95% certainty, indicated by Grubbs.T_950, which a constant variable hard-coded into the Grubbs class.

When run, the console prints:

Outlier?: 0

This means that the outlier lies at index 0. That's value '30', which we guess earlier was an outlier. But that's only 95% certainty that 30 is not part of a normal distribution. What if we wanted to be 99% sure?

I repeated the test, but replaced Grubbs.T_950 with Grubbs.T_990 (other t-distribution set of values I hard-coded into the Grubbs class). The console printed:

Outlier?: -1

Recall that our findOutlier() function returns '-1' if no outliers are found. This means that we cannot be 99% certain that the value '30' lies outside of normal distribution. (Though we can be 95% certain, as shown above!)

Well, that concludes this tutorial! Hope this helps some, in whatever random case you happen to need outlier elimination in ActionScript!