How to check that a sequence of numbers is random? [duplicate]

I have a sequence of numbers like 1,7,22,45,12,96,21,45,65,36,85,14,51,16,18,17,16....65...

IS there any formula to check whether the sequence is random or not ?

In my case

1. odd numbers are not random since previous+2
2. even numbers are not random
3. the numbers can be repeated in a sequence but must be far away,
4. we cannot generate the sequence using any formula like (x+2)^2 -2x like...
-

marked as duplicate by LTS, user127096, voldemort, Mario Carneiro, Claude LeiboviciApr 12 '14 at 4:53

And how do you define random? –  Sasha Sep 28 '12 at 14:20
@Sasha In my case 1.odd numbers are not random since previous+2 2.even numbers are not random 3.the numbers can be repeated in a sequence but must be far away, 4.we cannot generate the sequence using any formula like (x+2)^2 -2x like... –  cc4re Sep 28 '12 at 14:21
Would the distant digits of $\pi$ count as random - even though they are computable? Randomness is a difficult concept to capture, and is also very important, since the generation of random (or pseudorandom - ie looking random on common tests) numbers is commercially important [think codes and confidential communication]. A readily computable formula or algorithm to identify and predict all pseudorandom sequences would have significant consequences in the real world. –  Mark Bennet Sep 28 '12 at 14:33
Your property 3. is opposite to randomness. –  Did Sep 28 '12 at 15:18
Maybe this will be of interest: en.wikipedia.org/wiki/Diehard_tests –  Byron Schmuland Sep 28 '12 at 15:33

There is a very good discussion of this question in Seminumerical Algorithms, which is Volume 2 of Knuth's The Art Of Computer Programming.

-

First of all you have to tell what "random" means...

But in the algorithmic context there is a nice definition.

To be more specific: a number $\alpha\in(0,1)$ is algorithmically random if for every $n$ the size of the shortest program giving you the first $n$ bits of $\alpha$ is at least $n$ bits long.

You can encode your sequence as a binary representation of some number from the interval $[0,1]$ and try to check if it is algorithmically random.

But do not count on a formula that can tell you if a particular number (sequence) is random since such a formula cannot exist.

See "Algorithmically random sequence" "Chaitin constant" and "halting problem" in Wikipedia for more details.

-