Thread: Hmm.. Ai? Finding the pattern in number squences?

  1. #1
    #junkie
    Join Date
    Oct 2004
    Posts
    240

    Hmm.. Ai? Finding the pattern in number squences?

    Ok, basically i am CLUELESS as to how this would work. But none the less i figured i would ask and give it some insight.

    I am trying to find a pattern with a few dif variables. It cannot be tested as you normally test things, its more of a living pattern if you will. Which makes it a bit harder. (ie i cant make all the variables stay the same and change one in many different ways and do that with each variable to get a better grasp. Basically they all change every.. we'll call it tick.)

    Now i have been trying to find the formula at which these variables are calculated and i believe i have enough information, but looking over the mass data is getting me no where with my little mathmatics knowlage (never took like advanaced alg or statistics classes) so i was curious if there was a way to program a.. program to figure it out.


    There is also a bit of randomness to these variables, but none the less.

    So, could anyone give me any pointers with the simple description i gave you? I mean is there a way to make a program figure out a pattern i give it?
    1
    4 (+3)
    3 (-1)
    6 (+3)
    5 (-1)
    ect..
    Thats an amazingly simple pattern, but can things like this be done? I assume this is partial AI, but its not learning persay, just doing what i told it to.. i dunno. Its hard to ask specifically what i need when i am so clueless to the pattern and my curiosity makes me need to know the formula behind it lol.

    Pointers would be awesome, thanks!
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  2. #2
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    alright im just gonna take a wild guess at this, can't be too hard

    you can kind of do something like this (note: my "style" of coding is really.... unclean, so you just have to bear with me)

    Code:
      int a,b,c,d,e;     //the 5 numbers that the user will input
      int pattern[50];      //50 because i'm not counting how much im going to actually need
      //....
      // put all the bullcrap entering of the numbers here
      //....
      
       //now to calculate the possible patterns (going by addition, subtraction, multiplication, and division only)
       pattern[0] = b - a;     //to find the sum that was added from a to get to b
       pattern[1] = b + a;   // to find the differance
       pattern[2] = b / a;    // to find the product that was multiplied to a to get b
       pattern[3] = b * a;   // to find the divisitidaslgasjg (i can't think of the word for division right now)
       pattern[4] = c - b;    //do the same for b to c
       //....
       //do the same for each letter
       //....
    
       //now you can check to see if there really is a pattern
       if (pattern[0] == pattern[5]) //pattern 1 would be the sum that was added to a to get b
                         //and pattern 5 would be the sum that was added to b to get c.
                        //if both patterns EQUAL, then there is one sum pattern
       {
          //..
          //do what you want
          //..
       }
      
        // and then you would go on to check if, lets say
        // pattern 1 and 10 (10 would be addition from c to get to d)
        // and then do the same thing over and over again
        // and idk im just giving you ideas on how it could be done
       

    OF COURSE, this would be a REALLy bad and complex way to do it, i'm sure others can think of a more simple solution

    i'm just trying to show you, how it can be done
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  3. #3
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    937
    This isn't exactly what you're asking for, but if oyu want to define your set of data with a function, you'd have to pass it through code that tries all different types of function with it: linear, quardatic, cubic, sin, tan, exponential, etc. It'd take literally forever-- but it works in theory.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  4. #4
    #junkie
    Join Date
    Oct 2004
    Posts
    240
    Quote Originally Posted by CodeMonkey
    This isn't exactly what you're asking for, but if oyu want to define your set of data with a function, you'd have to pass it through code that tries all different types of function with it: linear, quardatic, cubic, sin, tan, exponential, etc. It'd take literally forever-- but it works in theory.

    So to get a formula from a bunch of variables you just have to smash it with other formulas?

    I didnt think i was going to find a way to do this, but for all i knew there was a mathmatical technique to find a formula behind multiple variables. Well a simple one. I figured id give it a shot and see what masterminds came up with hehe, thanks guys
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Well there are many different types of patterns. If it's purely numerical data, you would check for recursive patterns and then for functions. Unfortunately, one can usually be expressed as the other, and there are infinite degrees of functions, so you'd have to learn a lot of calculus and other branches of math to be able to understand the logic behind finding out what is going on. Then there's fractal math. It's just too big a problem unless you're really going to get into this seriously.

  6. #6
    Flash Animator, OF DOOOOM bluehead's Avatar
    Join Date
    Nov 2001
    Posts
    269
    Oh, well, if your doing more complex patterns.. like, lets say f(x) = 2x^2 + 1... wow i dont think there is a way to code that.

    That's what pencil and paper are for.
    Code:
    #if _emo
      #define stereo_type_i_dislike
    #endif

  7. #7
    #junkie
    Join Date
    Oct 2004
    Posts
    240
    Ya, thanks everyone. But i was just curious mostly, and you have given me much info on whether it is worth it or not. And my curiosity is not that strong lol. I can toy with the numbers and find something much easier than making a program do it for me, so imma do that.

    Thanks again all
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

  8. #8
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Quote Originally Posted by bluehead
    Oh, well, if your doing more complex patterns.. like, lets say f(x) = 2x^2 + 1... wow i dont think there is a way to code that.
    Of course there is!

    Given an arbitrary sequence of numbers, it is quite easy to find a formula for the sequence: just interpolate a polynominal for the given points.

    Here's the source and executable for a program I wrote to calculate the formula for an arbitrary sequence of numbers.

    EDIT: Not the forumula, a formula. There are many possibilities

    Exe: http://www.strandmark.com/program/sequence.zip
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  9. #9
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    This is why I hate questions like this on IQ tests etc.
    If you ask someone to continue the sequence

    1,2,3,...

    most people would answer 4, but 100 is an equally valid answer, because the formula

    16n^3 - 96n^2 + 177n - 96

    generates the sequence

    1,2,3,100

    It's always possible to fit a polynom to any sequence of numbers.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. recursive finding index of the min number in array??
    By kavka3 in forum C Programming
    Replies: 5
    Last Post: 01-18-2009, 07:14 AM
  2. Finding The Hcf Of A Number
    By Saimadhav in forum C++ Programming
    Replies: 5
    Last Post: 10-31-2008, 06:50 AM
  3. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  4. Game Design Topic #1 - AI Behavior
    By TechWins in forum Game Programming
    Replies: 13
    Last Post: 10-11-2002, 10:35 AM
  5. Array of boolean
    By DMaxJ in forum C++ Programming
    Replies: 11
    Last Post: 10-25-2001, 11:45 PM