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

Printable View

• 04-01-2005
Zeusbwr
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!
• 04-01-2005
bluehead
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
• 04-01-2005
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.
• 04-01-2005
Zeusbwr
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 :)
• 04-01-2005
sean
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.
• 04-01-2005
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.

That's what pencil and paper are for.
• 04-02-2005
Zeusbwr
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 :)
• 04-02-2005
Sang-drax
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
• 04-02-2005
Sang-drax
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.