Jehoshaphat I. Abu


100 Days Of ML Code — Day 091

100 Days Of ML Code — Day 091

Jehoshaphat I. Abu's photo
Jehoshaphat I. Abu
·Oct 18, 2018·

3 min read

100 Days Of ML Code — Day 091

Recap From Day 090

Day 090, we looked at Sampling Rate

You can catch up using the link below. 100 Days Of ML Code — Day 090 Recap From Day

I promised you yesterday that I’ll explain it a little bit more formally what a sampling rate is and we’ll look at the Nyquist Theorem, which gives us some guidance on picking a sampling rate.


We learned a bit more formally about what sampling rate but didn’t get the chance to look at Nyquist Theorem.

Today, without further ado, let’s get to it.

Nyquist Theorem

The Nyquist Theorem says that the sampling rate must be at least twice the highest frequency that you wish to represent. This makes a lot of intuitive sense when you think about it. And the reason for that is let’s think about our sine wave again, here.

If I have a sine wave going at say 440 hertz then, I have 440 peaks and I have 440 troughs happening every second so the minimum that I need to capture digitally in terms of those dots, those amplitude readings would be for each cycle of my sine wave, I need to make sure that I have at least one sample to represent somewhere on my peak, somewhere above the zero crossing and then, something somewhere below the peak to represent below the zero crossing somewhere down by my trough.

So I need 440 peaks and 440 troughs or 440 above zeros and 440 below zeros to be able to capture these 440 cycles of my sine wave in a second. So I simply would multiply 440 by 2 and I’d end up with 880 as a sampling rate that I would need. So in reality, we’re not looking at every individual sine wave or frequency component that we want to represent, we want to come up with some general sampling rate that’s going to work really well for a lot of things so what should that sampling rate be? We can kind of deduce this logically.

We talked about the range of human hearing is going from roughly 20 hertz up to 20,000 Hertz. So if we take 20,000 hertz and we multiply it by 2, we end up with 40,000 Hertz. So, we know that the sampling rate must be greater than 40,000 hertz and so the number that we usually end up seeing is 44,100 Hertz. The reason for this has to do with the history of the early days of digital recording and some decisions at Sony and other manufacturers made in the late 1970s that aren’t really worth getting into here but that number has largely stuck that’s what we use on compact discs, in particular, is 44,100 hertz is their sampling rate.

You’ll sometimes see other sampling rates. You’ll see like 48,000 hertz for instance. You’ll sometimes see higher rates like 96,000 hertz or even 192,000 hertz it’s in very high fidelity recordings and the reason for that, of course, is that if we had a sine wave that is able to capture at least one sample somewhere on the peak, and one somewhere on the trough, but that’s not going to be enough to really capture the entire shape of that sine wave, that entire curve.

If you want to get a really nice representation of it, you’re going to want as many samples as possible all along the way. So, the higher a sampling rate is the better resolution we’ll get and the better we will be able to represent those curves.

That’s all for day 091. I hope you found this informative. Thank you for taking time out of your schedule and allowing me to be your guide on this journey. And until next time, be legendary.

Share this