Not understanding digital signal processing

Started by House_atr 2 weeks ago18 replieslatest reply 1 week ago168 views
I'm learning dsp by reading Understanding digital signal processing by Richard Lyons. 


I'm on chapter 2, aliasing. So here's my thing. I know algebra and I know trigonometry. I understand how Sine works and I understand it's repeating by 2pi. My issue with every single day book I try to read over the years is that the math in these books is impenetrable. Example: two values of a sine wave are identical if they are separated by 2pi. Makes sense, 2pi is a full cycle sin(theta) = sin(theta + 2pi * m) where m is any integer we can modify. Star symbol meaning multiply not convolution here.


Okay so far so good. Then the page of the book immediately goes into this monstrosity.

f: samples per second

t: 1/f

x(n) = sin(2pi * f * nt) = sin(2pi * f * nt + 2pi * m) = sin(2pi(f + m/nt)nt)


Yeah.. no explanation behind that equation. No steps. No idea. Literally every dsp literature has these nice surprises. You read and read and think you're understanding and things are coming together than that happens. Can someone please explain to me what that equation is. How are they all equal. I get it's saying they are equal because it's value results in multiple of 2pi and they are always the same value. Really any pi half pi double pi is the same between sines of the same frequency. I get that. But how does that equation express that? That kind of algebra warrants an explanation by the author but non is given.

[ - ]
Reply by Tim WescottJanuary 7, 2019

It does need to be broken apart, but it should yield given patience.

> x(n) = sin(2pi * f * nt) = sin(2pi * f * nt + 2pi * m) = sin(2pi(f + m/nt)nt)

First part:

> sin(2pi * f * nt) = sin(2pi * f * nt + 2pi * m)

This works because m is an integer, and if sin(th + 2pi) = sin(th), then by induction sin(th) = sin(th + 2pi * m).  Let th = 2pi * f * nt, and it works, right?

Second part:

> 2pi * f * nt + 2pi * m = 2pi(f + m/nt) * nt

This is just a rearrangement.  First get everything under the 2pi:

2pi * f * nt + 2pi * m = 2pi * (f * nt + m)

Now bring the nt outside of the parenthesis.  m isn't doesn't have nt as a factor, so you have to divide.  I'll do it in two steps:

2pi * (f * nt + m) = 2pi * ((f * nt)/nt + m/nt) * nt

2pi * ((f * nt)/nt + m/nt) * nt = 2pi(f + m/nt)nt

Now plug that back into your original equation, and you're done.

cannot stress enough that you can't expect to just read the math and understand it.  I feel like I'm a pretty hot-shot mathematically inclined engineer, more so than 90% of my peers*, and I can't do this just by looking at it.  If I'm serious about understanding a book like Rick's I read it sitting at a table with a pile of scratch paper and a pencil, and if there's a hint that I don't understand how you get from equation n to equation n+1, I work it out on paper.  Sometimes I'll get stuck on one such transition for hours, but I work it out.

It's not a bad idea, if you are stuck, to try working equalities out in reverse, or to plug in numbers and see how they work out.  Sometimes that'll get you unstuck.  You can always ask here.

* I may not be that good in truth, but that's how I feel, and I'm sticking to it.

[ - ]
Reply by House_atrJanuary 7, 2019
Thank you! nt was being extracted out since f is multiplied by nt, dividing cancels it. Since it is now outside the parens and is distributive over m, m must be divided by nt. I appreciate the reassurance to take things slow. I did feel inadequate to continue learning dsp but hearing some reassurance that sometimes it could take a day to put the math together tells me I'm not on the wrong path.
[ - ]
Reply by Rick LyonsJanuary 7, 2019

Hello House_atr. I just now saw this Forum thread.

My use of Eqs. (2-3) and (2-4) is my algebraic way of showing that Eq. (2-5) is equivalent to the last line of Eq. (2-2). And Eq. (2-5) is the key to my aliasing explanation. Eq. (2-5) states that two sine waves are aliases of each other (that is, at a common fs sample rate their x(n) sample values will be identical) if one sine wave's frequency is fo Hz and the other sine wave's frequency is fo+k*fs Hz. (Variable k is an integer.)

I'm sorry if my Eqs. (2-3) and (2-4) caused you heartache. I'll try to do better next time.

[ - ]
Reply by House_atrJanuary 7, 2019
This is very awkward. I honestly did not know the author was on this forum. First of all, your book is actually fantastic. The reason I got frustrated with this is because I really want to keep reading it and I felt this problem was a sign of more issues to come and I didn't want anything to stop me because so far this is the best book on dsp I've found to date. I especially like the little gentle nudges you give when you're introducing a topic, but are not ready to delve into yet "this is that and it kinda works like this, but don't worry about it too much for now; we will cover it in detail later". Very helpful to let me know to keep going and not stress out over a thing I was just told about but don't understand yet.


Someone here mentioned edition. I have a 1st edition borrowed from a friend. Should I get a later edition from Amazon?

[ - ]
Reply by Rick LyonsJanuary 8, 2019

Hi House_atr.

Your words didn't hurt my feelings, but rather they show me you are enthusiastic to learn more about DSP. You and I are kindred spirits. Thirty five years ago I was in a continual bad mood trying to learn DSP from the DSP books available at that time. You should have seen how hard it was to learn about the discrete Fourier transform (DFT) 35 years ago. 

Back then, trying to learn the DFT, I'd plow through three pages of a book's equations that I didn't fully understand. And the then the author would write, "And now for an example." which turned out to be just another equation. It was heartbreaking. (You won't have that problem as you go through my Chapter 3.)

Should you buy my book's latest (3rd) edition? At the risk of sounding like I'm trying to sell another copy of my book, I'll just say my 3rd edition expands on 8-10 different topics covered in the 1st edition and includes roughly a 12-15 new topics not covered in the 1st edition. Chapter 13 of my 1st edition contained 12 "DSP Tricks" while the 3rd edition contains 51 "DSP Tricks." (If you do buy a copy of the 3rd edition, the royalty I receive from that sale will enable me to buy a gallon of milk and a loaf of cheap white bread for my starving children.)

House_atr, as you continue to study DSP if you have any questions for me, no matter how trivial, please send me a private e-mail at: R_dot_Lyons_at_ieee_dot_org. I WILL reply to your e-mail.

By the way, Stephen Smith's DSP book, at: http://www.dspguide.com/ is a truly great source of information for DSP beginners. Smith is a very skilled writer. And in the future if your interests include digital communications I'd suggest you try to obtain the prolific DSP guru fred harris' book titled: "Multirate Signal Processing For Communications Systems." (And when I say "guru" I DO mean guru!)

Good Luck, and ...keep asking questions. As a DSP ol' timer once told me decades ago, "Asking questions leads to discoveries."


[ - ]
Reply by lmosheJanuary 9, 2019

Hi Rick,


I didn’t know you have a book. How/Where can I get it?


Thanks

[ - ]
Reply by Rick LyonsJanuary 9, 2019

Hi Imoshe. Of my books, the book we're referring to here is described on the following web page:

https://www.amazon.com/Understanding-Digital-Signa...


[ - ]
Reply by House_atrJanuary 10, 2019

Your reply is exactly what I needed to hear to give me a nice kick to keep going. I got similar replies from others I have talked to on the subject. It's emboldened me to push forward because this stuff is hard at first but I'm discovering it becomes very easy once the understanding is there. I'm starting out with no intuition for how signals work so the math really isn't the problem, but just my level of immersion. You're right about the mood. I'm seeing as I continue to read your book, my mood is improving and there's even an immense amount of excitement for what comes next. I guess like denial, this kind of extreme learning comes in stages. The anger was useful I think, it got me focused to tackle dsp and keep going (how dare this not make sense to me!?)


I'm waiting for a new copy of the book to deliver and this way I can buy you an extra small dunkin donuts coffee and maybe share a little of my blueberry scone. I have a small question, which I'll email you. I haven't replied until now because I've been busy and imagine you must be even more busy than I am so I hope its not annoying to ask a small trivial math question. I hope I put the address in correctly. Whenever you have time and thank you so much for the encouragement. As with a lot of subjects I've learned over the years, I always laugh at how incredibly naive I start out and wonder why was it that particular topic was difficult at all to grasp? It's so fundamental!

[ - ]
Reply by Rick LyonsJanuary 10, 2019

Hi House_atr. If you want to learn DSP, if you have enthusiasm and don't give up, you will learn DSP. To quote Susan B. Anthony, "Failure is impossible." Send me an e-mail any time you wish.

(PS. I'll have a maple-covered donut with my Dunkin Donuts coffee.)

[ - ]
Reply by adiduaJanuary 6, 2019

Every sinusoid has the following property: sin(x) = sin(x+2pi) = sin(x+4pi) ..., or compactly, sin(x) = sin(x + 2m*pi) for any integer m. Just think of the argument of the sinusoid x as an angle on a circle. If you add 2pi to x, you are back to where you started on the circle, so sin(x+2pi) = sin(x). Of course, this would be true if you added (or for that matter, subtracted) any multiple of 2pi. The came holds for cosine also, which is nothing bust a shifted sinusoid.


If you agree with the above, it follows that x(n) = sin(2pi*f*nt) = sin(2pi*f*nt + 2pi*m) for any integer m. Now, you can factorize the argument 2pi*f*nt + 2pi*m as 2pi(f*nt + m). Next, you can factorize f*nt+m = nt(f + m/nt) to get to the final answer. 

Hope this helps!


PS: Personally I am a fan of Oppenheim & Wilsky and Oppenheimn & Schafer, maybe because they were my undergrad texts.

[ - ]
Reply by House_atrJanuary 7, 2019
Thank you I finally got the algebra down on that problem.
[ - ]
Reply by SlartibartfastJanuary 6, 2019

Which edition of that book do you have?   I'm looking at a first edition and the text description around the equations seems reasonably thorough to me.   The progression from the sequence of equations in 2-2 is described in the text to get to 2-3, then the logical description from there to the subsequent equations.   The terms are described in the text.

Is there something specific you're missing?

[ - ]
Reply by shafie7January 6, 2019

If your question is regarding the following equation

x(n) = sin(2pi * f * nt) = sin(2pi * f * nt + 2pi * m) = sin(2pi(f + m/nt)nt)

Then, sinusoidal is periodic function, every 2pi, so m is an integer.  

Richard Lyon's book is one of the best book in DSP, if not the best.

Do you have any PDF copy of it? if so, send the link and I'll try to answer specific question.


Best regards,

Shahram Shafie

https://ortenga.com/

[ - ]
Reply by House_atrJanuary 6, 2019

@Slartibartfast & @shafie7


I believe first edition, printed. I don't see a text description of the equation. Here is the excerpt

Because two values of a sinewave are identical if they're separated by an integer multiple of 2π radians, ie., sin(θ) = sin(θ + 2πm) where m is any integer, we can modify as

x(n) = sin(2πf0ntₛ) = sin(2πf0ntₛ + 2πm) = sin(2π(f0 + m/ntₛ)ntₛ)


If we let m be an integer multiple of n, m = kn, we can replace the m/n ratio with k so that 


x(n) = sin(2π(f0 + k/tₛ)ntₛ)


Because fₛ = 1/tₛ, we can equate the x(n) sequences as


x(n)  = sin(2πf0ntₛ) = sin(2π(f0 + kfₛ)ntₛ)


Where do I even begin. Is the first equation saying that sin(2πf0ntₛ) produces the same value as sin(2πf0ntₛ + 2πm) the same value as sin(2π(f0 + m/ntₛ)ntₛ)? Obviously they do, but IS THAT WHAT ITS SAYING? Or is it some Algebra where each equation is rewritten as another equation? That's an important distinction. I already know sines of the same frequency are the same at 0pi and 1pi and 2pi and 2 and half pi etc. I know this. What is that full equation trying to express? Is it a proof? I can't manage to simplify the algebra behind it and the book doesn't even attempt to explain how it went from sin(2πf0ntₛ) to sin(2π(f0 + m/ntₛ)ntₛ).

[ - ]
Reply by Lito844January 6, 2019
I think the author is using the equivalency of the expressions in the last line of your excerpt to make a point about the sampling operation. The point being, once sampling occurs the resulting sequence no longer uniquely represents a continuous signal UNLESS certain conditions are met. This is the central issue of aliasing.


[ - ]
Reply by SlartibartfastJanuary 7, 2019

"Where do I even begin. Is the first equation saying that sin(2πf0ntₛ) produces the same value as sin(2πf0ntₛ + 2πm) the same value as sin(2π(f0 + m/ntₛ)ntₛ)? Obviously they do, but IS THAT WHAT ITS SAYING?"

There are equal signs between them, so, yes, that's what it's saying.   This is a hint to look and see what it is that makes them equal, and how it relates to sampling.  You only need to break down the arguments and understand that they're just phase arguments to the sin() function.  As you said, you understand that any sinusoidal wave is periodic over 2π, so 2πf0ntₛ yielding the same phase as 2πf0ntₛ + 2πm for any integer m should be straightforward.  It is just the same phase moved 2πm further down the sinusoid, so the value will be same for any m.  Okay so far?

The next step is just a little algebra on the phase term, first factoring out 2π, then factoring out ntₛ, 

f0ntₛ+ 2πm = 2π(f0ntₛm) = 2π(f0 + m/ntₛ)ntₛ

"Or is it some Algebra where each equation is rewritten as another equation?"

Yes, because the steps reveal the mechanisms that make aliasing behave the way it does.  Note how the phase arguments just sorted out above now show a bit more clearly how the sampling interval and signal frequency can interact.  The subsequent text is also pretty straightforward if you just absorb it as slowly as you need to and perhaps do like Tim suggested and just draw stuff out.

It's actually not that hard as far as discrete math goes, but the first time you see it it is foreign, just like anything else.


[ - ]
Reply by House_atrJanuary 7, 2019
Thank you I was able to solve why the sin equation was rearranged that way and I'm continuing to read the chapter on aliasing now.
[ - ]
Reply by kazJanuary 8, 2019

Post deleted by author