Algorithms

What I’ve been working on

Posted in Algorithms, API, Experiments, Flash on May 10th, 2011 by Ian Ford – Be the first to comment

I’ve been working on building a library for bezier curves and editable paths. I’ll share more results later.

Algorithms: Outlying Points

Posted in Algorithms, Article, Documentation, Experiments, Flex, Theory, Tips, Tutorial on December 15th, 2010 by Ian Ford – Be the first to comment

I thought it would be interesting to share some algorithms that can be used to solve problems you may run into while developing applications.

Given a variable number of numeric values, which of those values is the “outlier.” In this case, by outlier, we mean the most distant number. For example, given the set [1, 2, 3, 10], the outlying number is clearly 10 since it is further in value from the other numbers than any other.

How do we determine this? We calculate the sum of the distances from each value to each other value. That value looks like this:

The value in your list for which this expression is greatest is your outlier. This works for any set of values for which you can define a distance function. In the case of single values, the distance function is simply:


For coordinate values on a cartesian plane, the function is:

These can of course be extended into any number of dimensions depending on your needs. Here’s a demo that applies the idea.

In the demo above you can see that the outlying, or most distant, point glows in black. You can drag the points around and the outlying point will update accordingly. You can also see a skeleton drawn among the points demonstrating the values being calculated in our distance formula.