The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Algorithm Help

The first fixed number represents data for a monthly period. The second fixed number represents a percentage changed for the monthly period from the data this week to the data last week.

The array of numbers is a list of event that occured which caused in the percentage change.

The problem is the array of numbers can include data that had no real effect on the percentage change, so we dont want to include it. So I need an algorithm that can go through the array of numbers and determine what sort of effect it had on the percentage. If it has a large enough effect, print it out, if not, get rid of it. I also want to get rid of data that doesnt agree with the percentage change. For example, if the percentage change is negative, there should be no positive data included in the array of numbers.

So, when we look at the percentage and notice it is negative, we want to get rid of all the positive numbers, which brings our array down to:
Array of Numbers = {-150; -319; -1456; -700; -6420; -700; -350; -147; -290}

Now we want to have a look at the impact of each number of the percentage. Using common sense, I would narrow it down our Array of Numbers to:
Array of Numbers = {-1456; -700; -6420; -700;}

That seems about right, you might even consider removing the -700s as well.

Any thoughts on how to go about this?

EDIT: I have figured out the contradicting data fix but I still have not figured out how to sift through the irrevelant data.

Re: Algorithm Help

You could do this statistically but that's probably overkill. Another easier suggestion is for each number in the array, calculate its percentage contribution to the change. If this number is higher than a given cutoff, keep it, if not, toss it.