 This is lecture what? 22. Okay, so the last thing we were seeing was the trellis diagram for ISI AWGN, for the ISI AWGN model. Once again let me remind you, we are looking at a model where a simple sequence SK is going through an equivalent discrete time filter which is monic causal loosely minimum phase, do 10 BK to which noise gets added, which I know is IID Gaussian in both dimensions. And then I get ZK. So, I am looking at building an optimal detector here which will produce an estimate of s hat. So, that is easy to write down actually. So, you see s hat is argument of the minimum over A in XL summation K equals 0 to L plus mu minus 1, modulus ZK minus BK square. So, the extra terminations, the input corresponding to that is all plus 1, the way I assumed it, there is some chosen constellation point. So, this becomes well defined. So, the question as to why termination is needed, I will answer it as we go along later. So, this is what we are trying to build. And we immediately notice this is going to be incredibly complex for large x and large n. And we want to reduce it to a complexity which I said was suppose this is mu tab, I claimed we can do this with complexity, what? Size x bar, mu K roughly of that order complexity, we can do it. So, in particular at least it seems to be independent of L, but L will come as a linear factor somewhere here. So, do not think L is completely irrelevant, but it is a linear factor. So, every time we increase L just have to pay the same price. So, it is not too bad. So, that is the picture. So, for this, a structure which plays a crucial role in getting to this complexity is the trellis. So, the sequence of symbols which are produced by M of z can be represented on a trellis. So, that is the crucial idea. We saw a few examples and hopefully I also showed you an example of termination, how you have to shift in plus ones, then drive your state back to the known state at the end. So, those two things are crucial. So, any questions or comments? Is it ok? Everything is fine. So, my vector S in this situation is going to be S of 0 through SL minus 1. So, I have L data symbols followed by plus ones which are mu and number. That is for termination. So, this is for termination. I am saying plus one. So, you might have a situation where plus one is not in the constellation. So, then you have to replace it by anything. So, assuming plus one is always in the constellation, imagine an M PAM or M squared QAM in which case, if you think of QAM then maybe plus one is not there. So, this is mostly for BPSK case. So, imagine BPSK if you are getting confused. So, this is for termination. That is all I am going to imagine this. So, let us draw. So, what did I do? So, the trellis was basically a state diagram with a time axis. On each stage of the trellis, you had previous state to next state, transitions from previous state to next state caused by the current input SK along with it there was an output BK. So, that was one stage of the trellis. So, in general if you have to draw one stage, you would have previous states here and next states here. So, this I think I called psi k minus k then the next state would be psi k plus one. Then this is the kth stage and you have transitions. I guess you have transitions all over the place. I do not know how it will work out. It will be transitions all over the place and along with this stage we will associate a lot of things. One of the things we will associate is ZK. ZK will associate with this stage of the trellis. The reason is SK causes an output BK in that stage and BK noise gets added to BK to produce ZK. So, all these things make a lot of sense. So, another thing you observe from the objective function that we are trying to minimize there is one more quantity that I can potentially associate with this stage of the trellis. What would that be? In the objective function, this stage contributes something to the objective function. What is that contribution? The way I wrote it down. So, remember what is B here? So, let me qualify this with BA. What is BA now? BAK is what? AK convolved with MK. So, do not go back to the previous B and think that is the one. So, it is the B corresponding to the symbol A. So, look at the objective function for a while and tell me what component of that objective function is controlled by the kth stage? It is easy to see that. The objective function is a sum of several terms. There will be one term which corresponds to stage K. What is that term? Kth term. So, modulus ZK minus BK squared. So, nicely one can also associate the objective function as sum of several terms and each term is associated with one stage of the trellis. So, all these things are nice to see. So, associated with this stage is this ZK minus BK. So, that is how to picture the kth stage. So, this is how you, this is a picture that you should have in your mind whenever you think of maximum likelihood sequence detector. This is a picture that you should have in your mind. So, now, this function, so to speak, this part of the objective function has difference of two things. ZK which is common for all branches of the stage. So, every branch has ZK in common. What will differ depending on the branch? BK will differ. So, depending on which branch you are in, you will get a different BK. So, in fact, this term of the objective function, you can associate one such term with every branch. Depending on the exact BK that you had on that branch, you would associate a different term. So, in a way, this is a way of baiting your trellis. So, I am saying if this term is very, very small for a branch, what does it mean? Yes, probable that the transition would have happened. If it is very large, then it means then you are far away from that corresponding transition. So, in a way, this is a nice way to put on each branch. So, it is given a name, it is called branch metric. I will come back to it as we go along. So, now, so suppose you take one branch in the stage. So, you have a state i, you go to state j on a branch. Associated with that branch is a certain input. So, let me not put SK here. I will say I have an input and a certain output. So, this is one branch in a stage. Suppose this is the kth stage, then what I observe corresponding to this stage is ZK and the term that I am interested in in the objective function is modulus ZK minus the output corresponding to that state squared. So, depending on which branch I am on, that output will change. So, if I was in some other branch that output would have been different. So, what I am going to say is to this particular branch, I will associate a certain weight which will be modulus ZK minus output squared. So, that is all. So, now for different branches, I will associate a different weight. Now, this weight is a real number. There is no complex or anything. So, this is called the branch metric of the branch. So, it is important enough. So, I will give it a name. So, if you have, so this I will denote as BM subscript k i to j. What is that? So, this fancy notation, this is quite intuitive. At the kth stage, the branch metric for the branch from state i to state j. So, the states, so remember all these things are states, bunch of states. I am going to number the states from 1 to some ns. So, I can do that. What will ns be? Size x power mu. I am just numbering the states that way for convenience. Actually, the states, how do you think of the states? All the previous mu inputs, it is actually a vector. But I am going to just conveniently number it from 1 to ns. And of course, I can have a mapping from 1 to that if I want. So, it is not a problem. So, mod x power mu. So, this is for convenience. We will do that. And then associated to each branch in each stage of the trellis, I am going to associate a weight or a metric which I call the branch metric. I am going to denote that BM subscript k from i to j. If i to j is not possible for a certain branch, I can say it has got infinite weight, which means there is no way that is going to occur, it will not occur with very high probability. So, you will notice also the other intuition. If the branch metric is very small, it means the actual zk was very close to that corresponding output. So, that branch could have actually been traversed at the encoder. So, you do not know what was happening. So, that is the intuition behind why you define branch metric. Also the crucial thing is it plays, it contributes a term towards the ultimate objective function I have that I have to minimize. So, that is also the point. All right. So, that is with one branch in a trellis. So, now, suppose I give you the zk's, all the zk's, one can go ahead and compute the branch metric for every branch in the trellis. This is the computation we can do. You know the output corresponding to each branch, you know zk for each stage, you can compute. So, the weights can be computed for each branch. So, the branch metrics can be computed given zk. So, typically when you get the received values, you would compute these branch metrics and load them on to the corresponding branches in the trellis. So, you keep that. So, that is how you start. So, to proceed further, I have to interpret this arg min a in excel and the objective function in terms of the trellis. So, my entire decoding is going to happen on the trellis. Right now I am still interpreting my input symbols and outputs in terms of just entities that I defined before and I have not translated them into the trellis notation. So, I will have to now slowly make the transition and the transition is very, very easy to make. The crucial observation there is paths in the trellis. What do I mean by a path in the trellis? Some possible set of transition. So, set of branches in which you can go continuously from lift rate. It is a very intuitive simple definition. I can write down proper technical definition, but I guess it is not too crucial. When I say paths, it is very clear. So, basically a path will be, I can think of it as a sequence of states and it is possible to transition from one state to the next on a branch. So, it should be valid. So, paths in the trellis are defined like that. Now, suppose I ask the question in a trellis like I am considering right now, how many paths do we have? How do you answer that question? How many valid paths do you have on this trellis? New parallel. So, it seems complicated. So, first thing you have to do is, you have to associate paths in the trellis with something else you know already and then you will see this computation is very, very trivial. In fact, every path in a trellis corresponds to what? 1, a belonging to excel. Do you agree? Do you agree or not? Suppose I give you a belonging to excel. I can define a path on my trellis. How will I do that? a0 will be the input on the first stage. So, I know I took some branch and then a1 will be the input on the second stage. So, I can do that and define a path corresponding to a vector a. Once I do this, the answer is very trivial. So, how many paths are there in the trellis? Size x parallel. So, it becomes very easy, but this association is very, very crucial. Every possible input sequence into my encoder corresponds to a valid path on the trellis. It makes total sense, right? You have to traverse the trellis. You have to be on the state diagram. You can't just generally jump from here to that. Okay? So, as long as you are on the trellis, then it has to correspond to this. All right? So, that's the crucial link. Once you make this link, everything will become extremely easy. Okay? So, let me go back to this. So, once I have a path corresponding to a, in fact, I can index each path in the trellis with a. You can say path of a. What does it mean? So, when you input a to the trellis, what is the path it took? Okay? So, of course, I have the termination things adding on, but that's fixed. That doesn't change anything. That doesn't increase any possibility. So, this is the path corresponding to a. Okay? So, in fact, I can go a little bit further and say the path corresponding to a would be psi 0, psi 1a, psi 2a, so on. Right? Till what? Psi mu plus l. Right? Right? I know that my input a would have corresponded to a sequence of states. I can put them together and say that's my path. Okay? And I can even index that with a. Okay? So, when I ask for my decoding, I can either output a vector s hat or the path corresponding to vector s hat. Okay? So, I am slowly moving from the definition of the decoder towards the trellis. I am translating all the corresponding terms to the trellis. Okay? Right? Is that clear? So, why did I not put a for psi 0 and psi mu plus l? Yeah, it's actually independent of a. That's how we are fixing the encoder. Right? So, I can as well write psi 0 and psi mu plus l. In fact, psi 1 of a, I don't have to write the entire vector. Right? What will it actually depend on? Only a 0. Okay? But just for convenience, I'm going to put a. I can't keep writing something so carefully. All right? So, that's the thing for the path. Okay? So, the next step, if you go back and look at the decoder definition once again, one thing we have is vector a belonging to excel and that we have converted into a trellis quantity. The thing to convert into a trellis quantity next is this objective function. Okay? So, how are we going to convert that? I'll use the branch metric for that and it's very, it's quite straightforward. Okay? So, you see the path while it is being seen as a sequence of states can also be seen as what? Sequence of branches. Right? It's also a sequence of branches. Do you agree? It's a very easy thing to see. I mean if you went on a sequence of states and there would have been a branch between any two states and you put those sequence of branches together, you get okay? And each branch would have a branch metric. So, what do you do for the for the objective function? You add up all the branch metrics, you get a metric for the entire path and that I'm going to call as the path metric. Okay? So, if you want to be specific, how many branches will you have in a path? L plus mu, right? L plus mu. So, but the sequence of states will be L plus mu plus 1 because you have the starting and the ending. Okay? So, there'll be something like that. So, one needs to be careful there. I'm not going to spend too much time on it. Okay? So, based on this decomposition of the path, I can write path metric to be sum over branch in path branch metric. Okay? So, I know it's not a very nice mathematical writing with alphas and betas, but I guess this is clear enough. So, you see what it is. So, you take every branch in the path, take this branch metric, add up all the branch metrics, you get a path metric. Okay? So, I'm going to claim, so I should say, should be careful here. Okay, I should put A. Okay? So, it's okay. It's just an index with A. It's okay. So, sometimes I simply say path metric when the path is clear. Okay? So, I don't have to worry about it. Okay? So, now I have everything I need. In fact, this is going to be what? The objective function corresponding to what? A. So, in fact, this is going to be summation k equals 0 to L plus what? Mu minus 1 modulus zk minus BAK square. Right? So, I've already translated my objective function into minimizing path metric. Okay? So, it's once again, the intuition about path metric also should be clear to you. If your path has a very large path metric, what does it mean? It probably didn't really happen. Okay? The path has very low path metric. That path could have been traversed at the encoder. Okay? So, you don't know which path was traversed at the encoder. At the decoder, you have only noisy versions of the outputs. From that, you have to estimate the best path. And how are you going to do it? You're going to do it like this. Okay? S hat is going to be, okay? Argument. Okay? So, I'm going to say path of S hat. Sorry. Argument of minimum over path in trellis for what? The path metric. So, now we have a completely trellis description of the decoder of the MLSD. Okay? The maximum likelihood sequence tic-tac can be given a very simple and nice trellis interpretation. So, you go over all the paths in the trellis and find that path which has the least path metric. Okay? It's the exact same thing. I've not changed anything. It's just a way of looking at it. It simplifies this. All right? Any questions? Is that fine? Okay. So, that's with the path metric. And so, I'm going to postpone an example until until later. Okay? So, I want to do the definition of the algorithm formally and then I'll do an example later. So, hold on for a while if you see that all these notation is confusing you. Be patient with me. So, eventually we'll get there. Okay? So, so, so, so, so, so. Okay? All right. So, now comes the crucial part. Okay? So, previously when we were viewing the, the, so how many paths did we have here? We had size x power L. Okay? So, it's not clear why this will greatly simplify the problem at all. Right? How many possible paths you have to consider the same number? So, what's the big deal? Why is there a simplification? Okay? So, that's the question that you have to ask. The simplification comes because you can, once you think of it as a path, you can view the optimization slightly differently and suddenly you get a massive simplification. Okay? So, the way to view it is to say the set of, so, you take a path. Okay? So, suppose you take a path. Okay? So, I will a path look. I have my psi 0 and I have my psi L plus mu. Okay? And then, is there a question? Okay? So, suppose you look at the, let me say, I think I've put the k minus one stage. I mean, it doesn't really matter. Some stage, 1, 2, okay? NS, 1, 2, NS. Okay? So, this is, suppose is psi k minus 1 and this is psi k and you have z k minus 1 here. You know, sorry, this is a trellis. Okay? So, if you think of a path on this trellis, it's going to start here. What is it going to do? It's going to do something. Okay? Right? So, all kinds of paths will be there and then it will go this way, this way, this way, all kinds of paths will be there. Okay? So, I don't have to worry. So, there's really no discrimination possible. Okay? So, the way to discriminate, it's a crucial idea. Okay? It's very powerful in several places is to focus on a particular stage and only look at those paths that pass through a particular state at that particular stage. Okay? So, I'm going to say at the k minus 1 after the k minus 1 stage. Okay? So, psi k, I'm going to focus here and say I want to look at all paths that go through state i at after the k minus 1 stage. Okay? So, I want to look at all paths such that what? Psi k equals i. Okay? So, instead of just, that's how I'm going to discriminate between the paths to quickly do my minimization. Okay? So, I need some discrimination between the paths and the way I'm going to discriminate this, I'm going to focus on psi k, which is the kth state that the path goes through. I'm going to say I'm going to look at all those paths in this tell us whose state after the k minus 1 stage is i. Okay? So, now, once I do that, you'll see the picture will change. How will all these paths look? Now, suppose I say I don't care about this path. Right? I don't care about this path because it doesn't really go through i. I only care about those paths which go through i at the kth stage. So, how is that going to look? Well, maybe this is all okay but okay? So, the picture you see will change. Okay? So, you'll have something like this going from here and then everything else you have will meet at i. Do you see that? Okay? Maybe something else. Do you see that? So, this set. Okay? Right? Of course, there are other paths in the trellis but only those paths I'm looking at which go through the state i after the k minus 1 stage. Then I have this kind of a picture. Okay? So, now suppose I say I want to find the minimum metric path among only these paths first. Okay? See, if I have a whole set of paths, I can split them into different partitions, find the minimum in each partition first and then find the overall minimum. It's the same. I can do that any number of ways. So, I'm going to say instead of finding the overall minimum, I'll first look at the smaller set of paths which kind of get pinched at the id state after the k minus 1 stage. Okay? So, something like this. And I want to now ask the question, is finding the minimum metric path among these paths any simpler? Okay? So, the reason is now you can split between the path before psi k and the path after psi k. Okay? Once you know that you went through the id stage, you can look at the paths, the partial path up to psi k and minimize there and then look at the path from psi k to psi mu l plus mu minimize there and put both together, you will get the minimum. Okay? Right? Because I know I went through i here, I can split it into two. I'll say I do the minimum for the first part and then do the minimum for the second part and put it together. I should get the overall minimum. Okay? So, and that's that's crucial. There are several things that are crucial here. One crucial thing, obviously, you will agree is I am focusing only on parts that are going through id stage at the k minus 1 stage. Another crucial thing is termination. If I did not do termination, I wouldn't know that my final status psi l plus mu, then I still this this will not appear. This will not apply. Okay? This applies because I know I started at the common state. I am at a common state somewhere in the middle. And then I will also end at the same state only since all these three are true, this splitting of the minimization applies. So, that's the crucial part of termination there. If you did not terminate, if you don't know which state you will end up in after that, you can still apply this. You never know. There might be something else which suddenly makes the minimum. Okay? So, I don't think about it. It's a little bit. See, it might seem simple than I stated this way, but it needs some proving and it needs to be carefully understood. Okay? So, think about it more. I'll try to write down a few expressions to give you some idea, but without that it's tough to do. Okay? So, the way you prove this result, the result that I stated which seems very intuitive and nice to you, how you prove it is, you say suppose I look at path star which is argument of minimum over path in. Okay? So, maybe I'll call this set p i, p k i, path in p k i, path metric. Okay? Suppose I look at path star. Okay? So, I'm claiming if you restrict path star to, okay? So, I'm running out of space here. If you restrict path star to what? From 0 to k minus 1. If you restrict path star to 0 to k minus 1, this is going to be what? Argument of minimization path in this entire set restricted from 0 to k minus 1 path metric. Okay? In fact, even the other result is true. Path star restricted from k to l plus mu will be the argument of the minimum over paths in p k i restricted from k to l plus mu of the path metric. Both of those will have to be true. The reason is, suppose this is not true. Okay? Suppose this is not true. Suppose there is some other path here which is actually giving you a partial minimum. What can you do then? You take this path, put it along with the path star restricted from k to l plus mu, then you will get a overall minimum which contradicts path star. Okay? And you can do the same for reverse. But if you did not have yourself ending at the same state, you can't do that. Okay? So, think about it very carefully that contradiction will not happen. Okay? So, you can prove this by contradiction. Assume the opposite and then prove it. Well, it can end anywhere. See, at psi l, if you look at psi l, right? Psi l can be anything. It can be from 1 to ns. Psi l plus mu I know is fixed to be 1 or whatever number you choose. Okay? So, it can be anything. So, my path will start at psi 0, but it will end at anywhere. So, here I don't consider those things. After that, it has to go back to psi l plus mu. And the outputs I got for the termination are crucial because that will give me my branch matrix there and all that you have to use. Okay? Of course, there are versions of Wittebhi which you modify even when you don't have termination and give you approximate results which are very good. But if you don't terminate, it's not optimal. Which is not. Okay? So, I'm not going to go through every step of this proof, but I hope it's intuitive and clear to you. Right? It's not, it's not, it's not all that difficult to see. So, because you're going through a particular state and because you're starting at the same state and ending at the same state, it has to happen that you can do a partial minimization over this thing and it has to work out. Okay? Both ways. Because if it doesn't, then you can replace it by something else and you'll get a contradiction. All right? So, that's the thing. So, once you know this, it turns out that doing this minimization is easy. This minimization is appears to be, well, we haven't really come to that. Seems to be easy. Seems to have some structure. But how do I actually execute it? The problem with the execution is I have this k disturbing me, right? If I change k, things are changing. So, what actually happens in the Wittebhi algorithm is you start with k equals 0 or a particular k where you know something, where you know the minimization and then find the minimum for k plus 1. So, Wittebhi proceeds iteratively on this k. So, you start with k for which this problem is solved, for a particular k where the problem is solved and then using that you solve the problem for k plus 1. So, that's how it works. So, this path star has a special name. It's called the survivor path. So, what's my survivor path? So, I'm using a lot of notation here. Hopefully, it's reasonably clear. I mean, it's without that notation, it's tough to keep writing long statements in English. So, what is my notation? Let me once again remind you. pk i is a set of all paths which end at psi k will pass through i after the k minus 1 stage. So, then if I put a bar to the right and put some indices there, it means I'm restricting that to a suitable number of stages. So, that's what it means. So, that notation is hopefully clear. So, then there is my survivor path. So, that is called my survivor path. So, so that's a crucial definition. So, I'm going to call it survivor path at the kth stage ending at well at the after the k minus 1 stage. It's going to be argument of minimization paths restricted from 0 to k minus 1. Did I put that right? What did I do? I said that it's some pk i, right? What do I do for pk i? pk i. So, overall paths. No, no, no. I'm sorry. I'm sorry. I'm sorry. This thing has a special definition. Not this guy. I'm sorry. This partial minimization has a special definition. That is the that is the thing. I'm sorry about that. So, let me write down carefully. I meant by that. Paths in pk i restricted from 0 to k minus 1 path met. So, I think I might be wrong with this index also. So, I should call it. So, I'm at the k minus 1th part. I'm saying I'm ending here. What am I doing? So, it should be size spk only. So, among these paths, which is the minimum metric path that is the survivor path. So, I've done the minimization up to stage k. Is that okay? So, I have to I'll define this for all i. That's called the survivor path. So, the next definition which is closely related is what's called the state metric, which I'm going to denote SMK i. For every i, I'm sorry. For each i. So, let me write it down clearly. So, it's not you don't do any further minimization for each i. So, how many survivor paths do you have at a particular stage? NS, size 6 per mu. So, that's that many survivor paths you'll have. The state metric once again is for each i. This is nothing but the path metric of the survivor path. So, remember once again the picture here. So, among all these paths, there is one path which I'm going to draw say with red, which is the survivor path. And the metric of that path I'm going to associate with that state. I'm going to call it the metric of that state. So, among all those paths, there's one path which has the minimum metric. In a way, it's called survivor because you have to only keep track of that path. You can forget about all these other paths. Because in competition with this path, all those other paths will lose right there and I don't have to consider anything. So, that's the minimization. All right. So, that's the state metric and the survivor path. So, the crucial step in the Viterbi algorithm is finding SP k plus 1 i and SM k plus 1 i. Given SP k i and SM k i, the state metrics and the survivor paths at just before stage k, how do you find the survivor paths and the state metrics after stage k? So, that's the problem which is solved in the Viterbi algorithm. So, once you do this, you just repeat it for every stage and you have solved the detection problem. So, that's the crucial thing. So, let me once again remind you what the picture is. The picture is something like this. NS, we'll do a general i. So, this is psi k and you also have 1, 2, some other J and NS and this is psi k plus 1. So, assuming I have, so let me draw this in red because this is going to be survivor paths. Assuming I have stored the survivor paths for each of these things and assuming I have the state metric for each of these things, how do you compute the survivor paths and the state metrics for the next stage? So, how do you join this? That is the problem that is solved in the Viterbi algorithm. It's very, very, very simple. So, you'll see and say write it down. It's extremely trivial. So, you said basically you find solve this problem. I'm going to find i hat which is argument over minimization over J such that, maybe i such that. So, I'll do J because I've done J here. J to i exists. State metric at J plus branch metric k from J to, so it's very, very simple. Suppose I look at the i'th, sorry the i'th, i'th state here, what am I going to do? I'm going to see back and figure out from which states I could have come in. Suppose this is a binary input thing, size x is 2, then I would have had two possibilities, maybe this and this. I have two possible previous states from which I could have come to i. What am I going to do? I have to simply pick which one of these could have happened. So, I go back and say my state metric at 2 was Smk of 2. I'm going to add that to the branch metric k from 2 to i. So, maybe I should put a J here, just to be consistent with my notation. And here I'm going to look at the branch metric from J to i. So, I think this picture is getting really, really busy. Hopefully, you can see something out of it. So, finally, once you do that, you get your most likely thing. So, suppose the top one was smaller, I'm going to say this was my chosen survivor path. So, if that path was less, I'm going to choose that. So, once I do that, how do I update my, once I find i hat, how do I update my spk plus 1? It's very easy. So, I'm going to say sp, right on this leftmost side, k plus 1 of i equals spk i hat. And then to that, what will I add? The survivor path ending at i will be the survivor path here. And then to that, i itself, right? So, you simply add i, okay? It becomes the survivor path instead of find the previous survivor path. And to that, you add i, okay? Because you know you're at i, okay? So, now what's the state metric at k plus 1? Simply the metric of this to the previous state metric, you add the branch metric that was chosen. So, that's the simple nature. And you repeat this for all i, okay? So, you have to do this for all i, all right? So, that's the WTW algorithm. Is there a question? It will be order of 2 mu. So, in terms of what and why are you saying this will be more because oh, because you're including the computation that's being done at each stage, okay? I'll come to it. We'll look at a careful accounting of the computation as we go along. For now, let me let me finish up the whole algorithm, okay? So, this is the, so I'm going to put this entire thing into an algorithmic format and they'll call it the WTW algorithm, okay? So, the input, okay? So, the input to this WTW algorithm is zk, okay? Between 0 and l plus mu minus 1. I'm also given the trilless, okay? So, I'm going to say I'm given the trilless and I'm also given psi 0, psi l plus mu. So, all these things I know, okay? All right? So, first step is to compute branch metrics for all branches, okay? In all stages. And then, you initialize the survivor path at 0 of psi 0 to simply psi 0. And you don't worry about the survivor path for any other state at 0 because you know at 0, you are at 0. And then the state metric corresponding to psi 0 would be 0. And in fact, in implementations, people usually set the state metric for the other thing to be very, very large. Other states at 0 to be large, just to, just an implementation detail. It's not too important, okay? So, for k equals 0 to l plus mu minus 1 for i equals 1 to n s. It's a number of states. The operation you do is i hat equals argument minimum j such that j to i exists in stage k. So, remember in the initial and termination stages, some branches don't exist. And they'll suddenly show up in the next stage. So, just to be convenient, for convenient notation, I am going to say this, okay? I will add smkj plus branch metric k from j to i. Here, I do the argument of the minimum. Among the previous states, find that state which gave me the least transition into this stage, least weight transition into this stage. I do that. And then I update my spk plus 1 i as spk i hat and then i. This is also possible to do smk plus 1. So, smk plus 1 i would be smk i hat. It's very easy plus smk i hat to i, okay? So, you end your two loops, okay? So, you end i and k. Then what will be your output? Your output is what? sp l plus mu of psi, okay? So, I have our path at the final state. Yeah, I know that's unique. There's no problem. Once I've terminated, I'll have only one sum of a path at the end, okay? So, that one, I'm going to output and that will correspond to the path of s hat. So, you go on that, you come back on that path and figure out what s hat would have been transmitted, okay? So, this is the Wittebi algorithm in a state in a very simple way. It's very trivial to write a program for this. Given the mk, let me not say very trivial. I don't know what's trivial and what's not trivial these days. So, it's very easy to write a program like this. It's not too difficult, but you have to pay attention to some details when you want to write a program for this. For instance, people will never compute branch metrics for all branches at the beginning, okay? So, I just put that for notational convenience here. Where can you compute the branch metric? I'm sorry? For every stage, why would I want to do it at every stage? Instead of computing it ahead of time, yeah. So, then I have to use only a small amount of memory, okay? So, only corresponding to each thing. That's one thing. The other thing is, you'll see a lot of these branch metrics will be very similar. A lot of symbols are repeated, right? You don't have to compute them differently for each symbol. All of them will have the same branch metrics. And in fact, when you look at mod z of k squared, z of k minus b of k squared, if you do that times it's conjugate, you'll see mod z of k squared as well alone will come separately. And there's no reason why you should compute that, okay? So, you'll only compute terms where b of k actually appears. In some cases, mod b of k squared also will become a constant. So, you can even throw that out, okay? So, you can simplify that computation. Another thing to pay attention to if your L becomes really, really large is your state metrics might blow up to a very large number, depending on how noisy or how less noisy your system is, okay? Your state metrics might blow up to a very large number. So, how can you deal with that in a program? Yeah, exactly. So, that's the thing. So, every time when you compute new state metrics, you can subtract an arbitrary amount to all of them and it won't make any difference to the derivation. Why? At any point, you're computing two state metrics at a particular stage. If you had subtracted something common among all of them, it still won't make a difference. All of these things are useful things that people do in implementation. So, you subtract a constant amount from all of them. Usually that's the minimum things like that. Okay? So, those are all quick hints about programming. In case you run back to your hostel rooms and open up something and start implementing a Viterbi decoder. It's a useful thing to have if you're planning to do something it's a Viterbi equalizer. It's a useful thing to implement and have it. Okay? All right. So, I think I'm going to stop here and do an example on Monday. Okay? Because I think the example here, I'll be able to start but I won't be able to finish. So, I'll start. Do the example on Monday.