HN Theater @HNTheaterMonth

The best talks and videos of Hacker News.

Hacker News Comments on
Wavelets: a mathematical microscope

Artem Kirsanov · Youtube · 148 HN points · 2 HN comments
HN Theater has aggregated all Hacker News stories and comments that mention Artem Kirsanov's video "Wavelets: a mathematical microscope".
Youtube Summary
Wavelet transform is an invaluable tool in signal processing, which has applications in a variety of fields - from hydrodynamics to neuroscience. This revolutionary method allows us to uncover structures, which are present in the signal but are hidden behind the noise. The key feature of wavelet transform is that it performs function decomposition in both time and frequency domains.

In this video we will see how to build a wavelet toolkit step by step and discuss important implications and prerequisites along the way.

This is my entry for Summer of Math Exposition 2022 ( #SoME2 ).
My name is Artem, I'm a computational neuroscience student and researcher at Moscow State University.
Twitter: @artemkrsv


OUTLINE:
00:00 Introduction
01:55 Time and frequency domains
03:27 Fourier Transform
05:08 Limitations of Fourier
08:45 Wavelets - localized functions
10:34 Mathematical requirements for wavelets
12:17 Real Morlet wavelet
13:02 Wavelet transform overview
14:08 Mother wavelet modifications
15:46 Computing local similarity
18:08 Dot product of functions?
21:07 Convolution
24:55 Complex numbers
27:56 Wavelet scalogram
30:46 Uncertainty & Heisenberg boxes
33:16 Recap and conclusion

Credits:
Vector assets: freepik.com
- Microscope vector created by freepik -https://www.freepik.com/vectors/microscope
- Lab room vector created by upklyak: https://www.freepik.com/vectors/lab-room
- Semaphore vector created by macrovector: https://www.freepik.com/vectors/semaphore

Mathematical animations were done using manim (https://docs.manim.community/en/stable/) and matplotlib python libraries.
3D animations were done in Blender
HN Theater Rankings
  • Ranked #8 this month (apr/may) · view

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this video.
To expand the insight, you may see this video about Wavelets which relates them to the Fourier transform.

It explains wavelets as an intermediate point between pure waves (all time, no frequency representation) and the Fourier transform (all frequencies, no time representation), with wavelets having part of both.

https://www.youtube.com/watch?v=jnxqHcObNK4

lupire
"time" is present in both frequency and position. The difference is how time is sampled. Fourier Transform maps between global frequency space sampling and (repeating wave for all time) and local positional/point space sampling (perfect impulse).

Wavelets map to an intermediate space,as you say, with smeared points/impulses and damped waves.

dsego
In this aspect, are wavelets similar to how stft is done with a hann window or the like?
Wavelet transform. This video by Artem Kirsanov made it click immediately, to the point I could implement it in Python right after watching the video: https://www.youtube.com/watch?v=jnxqHcObNK4.

For the uninitiated, wavlet transform is basically Fourier transform on steroids. Not only does it tell you what frequencies are present in a signal, it also tells you when they are present giving you a time vs. frequency plot (similar to short-time Fourier transform). Of course there is a limit to how well you can know both at the same time (just like the Heisenberg uncertainty principle actually!), but it's a very useful tool for studying signals. In my specific case, I was analyzing signals from a pulse oximeter in order to extract the breathing rate from them (https://dl.acm.org/doi/fullHtml/10.1145/3460238.3460254), but it has applications in many other fields such as image processing and compression.

Nov 13, 2022 · 148 points, 18 comments · submitted by peter_d_sherman
teleforce
Wavelet is not a true native time-frequency technique, technically it is time-scale in nature [1].

The better approach with better resolution is to use native time-frequency technique for example non-linear Cohen class time-frequency but currently it requires massive computing resources even for a short duration [2]. Hopefully with the available of cheaper RAMs in the order of Terabytes it will be more feasible to use proper time-frequency techniques for big data signal processing.

[1]Wavelet:

https://en.m.wikipedia.org/wiki/Wavelet

[2]Bilinear time–frequency distribution:

https://en.m.wikipedia.org/wiki/Bilinear_time%E2%80%93freque...

laszlokorte
Inspired by this excellent video I just built an visualization to dig further into the relation between short time fourier transform and wavelet transform. [1]

Its not quiet done yet and misses some polishing but I find it already helpful rightnow.

[1]: https://static.laszlokorte.de/time-frequency/

nigma
Wavelets are fun. I first heard about them in the early 2000s when I read about JPEG 2000 image compression format [1]. Back then the primary tool to play with signal transformation was the Matlab Wavelet Toolbox. As I got more interested in the topic I started work on PyWavelets [2] Python package for my master's thesis about medical signals processing and ML classification.

I'm not actively involved in the package development anymore but it is still maintained [3] and there is a great chance that you have it already in your Python environment as a dependency of scikit-image/scikit-learn. Just give it a try, it's very simple:

  >>> import pywt
  >>> cA, cD = pywt.dwt([1, 2, 3, 4], 'db1')

[1] https://en.wikipedia.org/wiki/JPEG_2000 [2] https://pywavelets.readthedocs.io/ [3] https://github.com/PyWavelets/pywt
mikewarot
The only aspect I can think of that was probably deliberately left on the cutting room floor is negative frequencies. When he showed the wavelet in 3d... it had a chirality to it, the same wavelet in the negative frequency would look identical, but would swap left handed/right handed threading.
rocqua
Still watching the video, but I know that, in finite cases, a 'negative' frequency (i.e. rotating counter-clockwise) can also just be interpreted as a positive frequency rotating more than 180 degrees per step that is rotating clockwise.

That only works in the finite case though.

GistNoesis
Signal theory 101 : You have some signal that you observe : v ∈ Rⁿ.

You have a database of k reference signals you know about vrefₖ ∈ Rⁿ.

What you want is to match the signal you observe to one of the reference signal.

This is called template matching : you pick the closest reference signal to the observation :

You compute argminₖ distance( v, vrefₖ)

This is great but it scales badly with respect to the number of reference signals.

So instead of trying to find the closest signal, you try to decompose the signal as a sum of reference signals :

You compute argmin over λₖ distance( v, Σₖ λₖvrefₖ)

This decomposition is not unique, so you regularize it (if your distance and norm are well picked the following is convex so you can get uniqueness guarantees):

You compute argmin over λₖ ( distance( v, Σₖ λₖvrefₖ) + Σₖnorm(λₖ) )

This is called sparse coding.

The rest (fft, stft,wavelet transform,...) are mathematical tricks (called transforms) to compute this more efficiently by choosing certain special reference signals (picking a basis).

The first math trick to be aware is (a-b)²= a²+b²-2ab : This is the bridge that relate what is called correlation to the distance :

for vector a,b ∈ Rⁿ : Σₖ(aₖ-bₖ)² = Σₖaₖ²+ Σₖbₖ²- 2* Σₖ(aₖbₖ)

With judicious pick the first two sums Σₖaₖ² and Σₖbₖ² can be made irrelevant to the minimization problem because they are either constant by construction (normalized to 1) or don't depend on the variable that we minimized over. This trick applies both to template matching and sparse coding (even though there is more terms they all simplify).

If the two first terms can be made to disappear then minimizing the distance has the same result as maximizing the correlation.

Then you have a bunch of sliding sums and recursive summation tricks which all depend on the specific shape of your data. Notably with fft there is the well known butterfly algorithm.

A century of techniques and theory since Hilbert have been devoted to finding various smart variants. And they allow you to compute this decomposition fast usually in O(n) or O(nlog(n)).

The alternative to hand-crafted techniques, is learning the reference signals from the data (Sparse dictionary learning). You can also brute-force your way through with deep-learned filter banks. It works better but require more compute, and have less guarantees. It also let you deal with nitty gritty details like missing data and masks.

Version467
Steve Brunton has some amazing videos on Wavelets on his Youtube Channel that are intended to be consumed alongside his book Data Driven Science and Engineering, but I found that they work great as standalone material as well.
meltyness
After learning of the Fourier transform in school, I immediately became interested in this for obvious reasons, but never successfully wrapped my mind around its employment usefully, beyond the jargon "wave localization."

The physical significance really arises from a place called the Huygens principle in mechanics, which supports claims about spatial wavefront propagation to state that at each timestep and point on the wavefront, another similar wave propagates, these subwaves are called wavelets.

this-pony
I'm a doctoral student working in the direction of PDE's and function spaces. I have some colleagues that are using wavelets for numerics. They typically prove that certain wavelet bases are better suited for numerical approximation of certain types of problems. You can for instance think about if you have a signal mainly composed of square waves. Then it would be rather inefficient to decompose this signal in sines and cosines. For certain types of PDE's under certain type of geometrical restrictions, sometimes you can find a much better wavelet bases than just sines and cosines. My research is rather theoretical (so I don't do any numerics), so wavelets don't play a role for me.
meltyness
I did my undergrad 10 years ago, and am essentially a hobbyist, myself currently working through Strang DE since I found Boyce uninstructive. The brief dialog on centered difference certainly raised my eyebrow, since Strang in an effort to more explicitly relate difference and differentials calls those out early, whereas the first time through the material I hadn't seen that interpretation until taking signals.
rajman187
As a funny aside, the author of one of the early works on wavelets [1] employed the first person plural pronoun with a footnote on the first page defining it as the “Royal we”

[1] https://arc.aiaa.org/doi/abs/10.2514/6.1994-2280

_jcrossley
Absolutely excellent. Thanks for sharing, I wish I had videos like this when I studied in undergrad.
rocqua
Stating that 'the time-frequency resolution trade off' is an instance of the uncertainty principle is at best a meaningless flourish, and generally speaking wrong.

If anything, the uncertanity principle is due to the time-frequency resolution trade off.

ohazi
This is easily the best video overview on wavelets I've seen.

I've used wavelet transforms on and off for years for things like image compression, harmonic analysis, and currently brain research, and I've always been somewhat disappointed in the quality of material that's out there explaining how wavelets work and how to use them effectively.

There's a small amount of "abstract math" heavy material but relatively little that's focused on using it for engineering, in contrast to all of the amazing material on Fourier transforms.

psychphysic
> currently brain research

Random shot in the dark. What do you think of the Free Energy Principle?

ohazi
I don't really have a horse in that race... it seems like a reasonable idea, but I don't think we're anywhere close to having the tools to confirm/deny it, or even to just observe what's going on with enough fidelity to make a guess.

My view of neuroscience is that we're decently good at figuring stuff out at the very very low level (e.g. behavior of complex molecules, classification of cell types and basic low level functions), and at the very high level (e.g. "this region is responsible for speech"), but haven't really made the right breakthroughs for figuring out the mid level (e.g. "how exactly does this ball of 50 million neurons perform its function, architecturally"). This theory seems to lie in that middle area.

psychphysic
Thanks!
peter_d_sherman
>This is easily the best video overview on wavelets I've seen.

Agreed completely!

That's why I submitted it to HN! <g>

HN Theater is an independent project and is not operated by Y Combinator or any of the video hosting platforms linked to on this site.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.