Welcome to the Java Programming Forums


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.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Algorithm Help

  1. #1
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,548
    Thanks
    24
    Thanked 299 Times in 282 Posts

    Default Algorithm Help

    I need some help creating an algorithm.

    Here is the problem:

    I have 2 fixed numbers, and then an array of numbers.

    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.


    Here is an example test case:
    Fixed Number 1 = 45,499,632
    Fixed Number 2 = -2.4%
    Array of Numbers = {-150; 750; -319; 60; -1456; -700; -6420; -700; -350; -147; -290}

    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.
    Last edited by aussiemcgr; September 10th, 2010 at 02:11 PM.


  2. #2
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,102
    Thanks
    169
    Thanked 779 Times in 725 Posts
    Blog Entries
    5

    Default 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.

  3. #3
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,548
    Thanks
    24
    Thanked 299 Times in 282 Posts

    Default Re: Algorithm Help

    I'm playing around with looking at the total number from the array vs each number's impact on the array. If it is above 14.5%, keep it, otherwise loose it.

Similar Threads

  1. Q:BackTracking Algorithm
    By Cross`17 in forum Algorithms & Recursion
    Replies: 0
    Last Post: April 17th, 2010, 11:33 PM
  2. Genetic algorithm
    By rpsaranya in forum Algorithms & Recursion
    Replies: 2
    Last Post: March 5th, 2010, 10:00 PM
  3. I have algorithm problem
    By Newoor in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 11th, 2009, 07:11 PM
  4. algorithm
    By AmmrO in forum Algorithms & Recursion
    Replies: 13
    Last Post: September 24th, 2009, 09:18 PM
  5. Insert sort algorithm
    By Alysosh in forum Algorithms & Recursion
    Replies: 1
    Last Post: May 26th, 2009, 09:28 AM