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 6 of 6

Thread: Parsing By Prediction Algorithm(?)

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Parsing By Prediction Algorithm(?)

    I've got a bit of a conundrum and can't seem to find any applicable information anywhere as to how to code some sort of predicting algorithm. Here's what I have so far:
    ArrayList<String> lotto = new ArrayList<String>();
    //Initialize lotto values//
    lotto.add("344167724");
    lotto.add("6413143");
    lotto.add("2");  //this value needs to be appended to either the one preceding or following it
    lotto.add("76111374132");
    lotto.add("44132");
    lotto.add("27446113");
    lotto.add("11");  //this value needs to (also) be appended to either the one preceding or following it
    lotto.add("4634181")

    Now I cannot use small numbers alone (5 is an acceptable minimum for my purposes here), so obviously the 3rd and 7th values here aren't any good on there own. Is there a way I can determine which value it likely belongs to using some sort of pattern recognition? And if so, where can I find any relevant information on it? Thanks alot!


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Parsing By Prediction Algorithm(?)

    This is not really my area but hang on for helloworld to show up, he seems to like these kind of things

    // Json

  3. #3
    Little Star
    Join Date
    May 2009
    Posts
    30
    Thanks
    0
    Thanked 9 Times in 7 Posts

    Default Re: Parsing By Prediction Algorithm(?)

    What are you trying to do? To gues a number? Or are you trying to create a list of random numbers?
    I don't quite understood what is your prediction supposed to be..

  4. #4
    Junior Member
    Join Date
    Sep 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Parsing By Prediction Algorithm(?)

    I'm trying to get my program to determine where numbers such as the 3rd and 5th belong, based on patterns that exist through the other 6 ("valid") numbers. Should the 3rd number be appended to end of 2nd number, or the beginning of the 4th? Something like that. Hope that clarified it.

  5. #5
    Junior Member
    Join Date
    Sep 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Parsing By Prediction Algorithm(?)

    Not sure if I was clear enough earlier, but I've been working on a sort of pattern assembler, trying to break the pattern down from numbers to a simple: "hi/lo/nc" (nc=no change)

    Here's what I've got at the moment:
        public static void pattern()
        {
            ArrayList<String> desc = new ArrayList<String>();
            desc.add("nc");
            String numbers = "3441677246413413"; //Here, I've taken the first two "valid" nums from above array
            int num1 = numbers.charAt(0), num2;
            System.out.println("---"+numbers+"---");
            for (int count = 1; count < numbers.length(); count++)
            {
                num2 = numbers.charAt(count);
                if (num2<num1)
                {desc.add("lo");}
                else if (num2>num1)
                {desc.add("hi");}
                else
                {desc.add("nc");}
     
                num1 = numbers.charAt(count);
            }
     
            for (int count = 0;count<desc.size();count++)
            {
                System.out.println(desc.get(count));
            }//end of for loop
        }//end of pattern() method

    Output is as follows:
    =====================PATTERN===============
    ---3441677246413413---
    nc
    hi
    nc
    lo
    hi
    hi
    nc
    lo
    hi
    hi
    lo
    lo
    hi
    hi
    lo
    hi
    This is the output for the first two "valid" numbers, and it could tell me if the third number (2) belongs in this sequence, simply by predicting if the next number should be higher or lower than the previous.

    Does this make sense? Anyone have any thoughts? Thanks!

  6. #6
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Parsing By Prediction Algorithm(?)

    hmm... what is this for? I can't seem to pick up any pattern in those numbers. I did some research on Lotto/Lottery, and it seems that it's based on choosing 6 random numbers, and depending on which lottery, the possible range for those numbers. In general, it's impossible to predict the results unless the mechanism for choosing the numbers is flawed/can be predicted. Further more, numbers are generally 1-49, or 1-99, not huge like those.

    For the computer to "figure out" an arbitrary pattern is beyond my knowledge... there are just too many possibilities.

    edit: haha, was typing this before you put your last post. I'll have to take a look at that later tonight when i have time.

    edit2: Yeah, I'm still lost at what it is you want. What larger purpose are you trying to satisfy here?
    Last edited by helloworld922; September 30th, 2009 at 10:28 PM.

Similar Threads

  1. Input file parsing to insert into DB
    By IDForums in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: September 30th, 2009, 02:29 AM
  2. algorithm
    By AmmrO in forum Algorithms & Recursion
    Replies: 13
    Last Post: September 24th, 2009, 09:18 PM
  3. Insert sort algorithm
    By Alysosh in forum Algorithms & Recursion
    Replies: 1
    Last Post: May 26th, 2009, 09:28 AM
  4. Printing xml to the console from .wmdb without printing junks
    By John in forum File I/O & Other I/O Streams
    Replies: 9
    Last Post: April 24th, 2009, 03:44 AM
  5. [SOLVED] Parsing ID3 tags from mp3
    By John in forum Java Theory & Questions
    Replies: 14
    Last Post: April 16th, 2009, 01:36 PM