# When mathematics lover meets Computer…

People often ask, why learn mathematics? Where do I apply it? Well this is how mathematics influences you everyday, every minute whenever you click and upload a pic. This post is going to be targeted for those who love mathematics and are mesmerised by its beauty.

Today I implemented very simple version of something known as Haar Wavelet Transform. I reached office early today, but no one had arrived yet so door was closed. The wiFi was on, that was enough for me. Actually, The day started with beautiful dream about my high school. I was literally smiling when I woke up. So back to office, I took a seat outside the door and as I was about to sit, I saw the self-taught mathematician I had told you about, coming out of Cafeteria.

He always has something or the other to teach me! We have rarely talked more than 15 mins in a stretch until today but he always blows me away in those 15 mins. Today out of no where he spoke about Haar Wavelets Transform and then after explaining it a bit, he told me to implement it today in Scala, which I am learning here.

So I am yet incompetent to explain you guys about Haar Wavelet Transforms, I will surely write another post for it. By then I will give you some links where you can learn about it.

http://www.whydomath.org/node/wavlets/hwt.html

Here is a simple python implementation of it – Github Python Implementation

Another CSharp Implementation – Github CSharp Implementation

And here is my Scala implementation(I know it is not very Scala idiomatic now, i am working on it) – Github Scala Implementation

if you notice, the lower coefficients are near zero. Just storing the higher coefficients of the wavelet can give u a good approximation of the data
this is used for histogram approximation http://www.bearcave.com/misl/misl_tech/wavelets/histo/
http://theory.stanford.edu/~matias/papers/wavelets-vldb00.pdf this has applications in databases where u need to keep a count of tuples in very range.

the transformed data is highly compressible, which is useful. One should learn the math behind it. how much is the error that u get if u throw away some coefficients ? thats a good question to answer.