Today i decided to test out a compression algorithm which i had in my mind for a few months.
Let us assume we have a binary file (picture file for eg) 2kb gif file.
The hex data being...
A9 B0 C1 D2 D3 F5 ED 34 ..... blah blah (2048 bytes long).
Let us treat this as a huge number ( when converted to decimal should be around 3000 digits length approx)
if we try to write this huge number in the format.. X^ Y + R
where 1 < X < N
&
1 < Y < N
for eg.. 34^3430 + 394
we just need this expression to reproduce the picture file.
The memory size to hold the expression is just 11 bytes for a 2048 byte pic file.
The idea looked convincing for me.
I searched the net and found one forum thread discussing this topic and it had information on why it won't work.
I decided to test it out myself. It just took me an hour to realize why this algorithm won't work out.
N = X^Y + R
On a few sample runs i found the best and worst case scenarios for this algorithm.
Best case would be,
when X=Y ( or approx equal) and R =0(or very small OR comparable with X and Y);
Worst case would be,
when N can be represented as M + 2*sqroot(M). where M is an integer.
Generally,
when N is represented as X^Y + R
and X and Y are greater than 1,
then the following holds good
1 < X < sqroot(N)
1 < Y < log2(N)
1 < R < 2*sqroot(N)
For worst case scenario.
X =~ sqroot(N)
Y = 2
R =~ 2*sqroot(N)
Generally if the number is n digit long.. then its sqroot will be n/2 digits long.
total expression length is (n/2 + 1 + n/2)
so the expression itself will be as big as the number.
The complexity is O(n)
For Best case scenario:
X =~ Log(N)
Y =~ Log(N)
R =~ X
Total expression length is Log(Log N) + Log(Log N) + Log(N)
so the complexity is (Log(Log N)) which is like 99.9% compression. :)
But the problem is , The probability that a bigger file falls near the best case scenario is very very very less.
Since X ^ Y are often separated by miles in the number line , especially when X and Y are large numbers.
Needless to mention that even for a super computer this algorithm would take years to encode bigger files.
Case closed. :)
Saturday, December 12, 2009
Sunday, May 03, 2009
Dreams!!!!!
I feel, writing about dreams would be a good start for my blog. Dreams are mystifying and creepy and i don't need any other reason to pick that topic.
So here it is! .
From Wikipedia:
Dreams are a series of images, sounds and feelings occurring in the mind during sleep, accompanied with rapid eye movement. Dreams typically last in the range of 5 to 45 minutes. The contents and biological purposes of dreams are not fully understood, though they have been a topic of speculation and interest throughout recorded history. The scientific study of dreams is known as oneirology.
Thats wikipedia way of telling.
"Digital projection of your mental self "? Naaaaaaahhhh... i know you heard that somewhere.
Well.. I don't know.. May be our Mind, mapped to a virtual world.
The "Common Themes" section in wikipedia actually reminded me about the dreams i had and i advise everyone to go over wikipedia to experience that.
My favourite dreams.. or dream themes..
1) Late for the Exam :
I frequently get this dream. Arriving at 12:00 for an exam which starts at 9.30 and i just have 30 mins. And, always there is a person who feels pity on me and he(?!) lends his pencil/pen. I am pretty sure that i never panicked and the dream-giver is sure that i can handle it :) . Nothing like the relief you get when you wake up and realize that it is just a dream.
2) Suddenly I am Naked:
Well, Nakedness in dream means a lot.
The way we react in the dream actually depicts our confidence and freedom.
If you are not ashamed then it shows ur freedom of thoughts
I feel a little ashamed and that explains all.
3) Falling :
The most common i would say. Nothing could beat the chill during the final fall and the virtual body merges with your real one and you wake up with a jerk :)
4) Falling in Love with Random people:
The scene is like i am in some restaurant kind of place with hanging plants (?!).
Random people?.. hmm.. not all the time..
5) Having sex :
Cannot ignore this. I wonder if there is any mind mapping involved here :)
It is not too hard to figure out why you are having wet dreams.
5) Searching for a toilet and piss:
Watch out - you are about to pee in your bed. Mostly you would be searching for a toilet in a party or a crowded place and when you are about to pass, you better wake up :)
6) A person who is dead being alive.
Well i would like to talk about this.
Some of the things i felt and experienced about this theme:
The dead person never actually initiates a conversation with you.
But he/she will be very eager to answer your questions. I wish and believe that they could foretell what is going to happen. Most of the time we end up asking the dumbest question to them.
Some other things.....
Though studies says that dreams are colored,
I don't recall any dream with mention of any color or any scene with color details.
Bad dreams does good things to us.
So here it is! .
From Wikipedia:
Dreams are a series of images, sounds and feelings occurring in the mind during sleep, accompanied with rapid eye movement. Dreams typically last in the range of 5 to 45 minutes. The contents and biological purposes of dreams are not fully understood, though they have been a topic of speculation and interest throughout recorded history. The scientific study of dreams is known as oneirology.
Thats wikipedia way of telling.
"Digital projection of your mental self "? Naaaaaaahhhh... i know you heard that somewhere.
Well.. I don't know.. May be our Mind, mapped to a virtual world.
The "Common Themes" section in wikipedia actually reminded me about the dreams i had and i advise everyone to go over wikipedia to experience that.
My favourite dreams.. or dream themes..
1) Late for the Exam :
I frequently get this dream. Arriving at 12:00 for an exam which starts at 9.30 and i just have 30 mins. And, always there is a person who feels pity on me and he(?!) lends his pencil/pen. I am pretty sure that i never panicked and the dream-giver is sure that i can handle it :) . Nothing like the relief you get when you wake up and realize that it is just a dream.
2) Suddenly I am Naked:
Well, Nakedness in dream means a lot.
The way we react in the dream actually depicts our confidence and freedom.
If you are not ashamed then it shows ur freedom of thoughts
I feel a little ashamed and that explains all.
3) Falling :
The most common i would say. Nothing could beat the chill during the final fall and the virtual body merges with your real one and you wake up with a jerk :)
4) Falling in Love with Random people:
The scene is like i am in some restaurant kind of place with hanging plants (?!).
Random people?.. hmm.. not all the time..
5) Having sex :
Cannot ignore this. I wonder if there is any mind mapping involved here :)
It is not too hard to figure out why you are having wet dreams.
5) Searching for a toilet and piss:
Watch out - you are about to pee in your bed. Mostly you would be searching for a toilet in a party or a crowded place and when you are about to pass, you better wake up :)
6) A person who is dead being alive.
Well i would like to talk about this.
Some of the things i felt and experienced about this theme:
The dead person never actually initiates a conversation with you.
But he/she will be very eager to answer your questions. I wish and believe that they could foretell what is going to happen. Most of the time we end up asking the dumbest question to them.
Some other things.....
Though studies says that dreams are colored,
I don't recall any dream with mention of any color or any scene with color details.
Bad dreams does good things to us.
Subscribe to:
Posts (Atom)