 So let us take a very quick review of what we did last time, so we looked at this autocorrelation function and in autocorrelation we also found out how to find out autocorrelation from sample autocorrelation function and from sample autocorrelation function we could estimate whether the random variables which are separated in time in the same time series okay in the same random process are they correlated. So this is normalized as you can see it is normalized function you normalize it with covariance at 0 and so the maximum value of the autocorrelation function is always 1 you can never get it is equal to 1 at lag 0 okay and at all other lags typically it is less than 1 it can be negative it can be positive but maximum value cannot exceed 1 okay. Now the question that we asked was is this correlation small enough to be neglected because even for a white noise process when you take a specific realization and compute autocorrelation you will never get equal to 0 so you have to take a call and something that is close to 0 and for that we found out confidence interval the idea for that was the way it was done was making use of the fact that the parameter estimate are themselves random variables the estimates of autocorrelation because we are generating them for the samples okay. So estimates this rho hat v tau themselves are random variables and you can show that their distribution is 0 mean with variance 1 by root n for large samples and the distribution is Gaussian so from that you are able to take come up with confidence interval and now I am not going to explain the concept of confidence interval you have to go back and revise this is start at some point in undergraduate so I have just shown here one calculation for 99% confidence interval if you take 200 samples and then how will you get estimate of this confidence interval. So typically 99% confidence interval or 95% confidence interval is used Matlab I will demonstrate the Matlab program it will typically give you 99% confidence interval and I have shown here for a white noise you know how do I compute this bounds I have taken a white noise which is Gaussian variance 1 you know mean 0 taken 200 samples in Matlab and found out realization for that realization I want to see if there is autocorrelation and autocorrelation as we have seen here it does not come out to be exactly equal to 0 it comes close to 0 and to take a call that it is close to 0 I have to use this confidence interval everything that is within the confidence interval is negligible I do not have to so this is white noise why it is white noise because all these autocorrelation values are small in the sense that they are within the confidence bounds okay. So you can view this sequence as you know white noise sequence then I just showed you an example from my lab this is experimental data sensor kept in a beaker for water at room temperature and then the data which I get is all over you know it is to find out what is the true value and you can appreciate that actual temperature in the beaker is not changing it is constant okay. So this is just a histogram of errors what I have done is I have taken mean value subtracted it from each observation and I got the errors in the measurement suppose we take mean as the estimate okay now you can estimate you can appreciate why the estimate of the mean is a random variable if I take some more samples I will get a different mean I will not get the same mean okay or if I take you know if I divide this into two parts 100 and 100 I think there are 100 points if I take first 50 I will get another mean each one of them is an estimate and that estimate only when you take all possible realizations you will get the true value okay otherwise what you get is an estimate okay and then that estimate itself is a random variable that estimate has a distribution and then you can talk of confidence interval and so on okay. So now question is this measurement sequence is the noise error in the measurement is it a white noise okay now same thing I have done I have found out confidence interval and you can see that autocorrelation function is you know all these values which you get for lag 1, lag 2, lag 3 up to 20 lags it is within the confidence bounds so this is practically a white noise okay. So if you take more and more values this estimate will become sharper and sharper and will go closer and closer to 0 if I were to take 1000 samples or 2000 samples and will actually analytically come to that why you should take more samples anyway this is I have just fitted a distribution into that data which I got this is another data which I had shown you the temperature global temperature data which is yearly global temperature average data I wanted to know whether there is a autocorrelation in this series which mean what is happening now is it related to what has happened in the past and this simple autocorrelation estimation shows that almost there is a autocorrelation for past 30 years what has happened now is a cumulative function of what is happening over last 30 years it is not just so there is lot of memory into the system okay now how to uncover and get a model we will see we will come to that but at least we know that this is not a white noise okay my bounds here are given here it is point it comes out to be some point to something so it is far away from the white noise okay when it is not white we call it as a colored noise why we call it colored I will come to that or why we call white noise as white noise this is the speech data okay again you can see there is a correlation between what is happening at one time instant and what is happening with some lag that is something in the past lag means in the past okay so the data is autocorrelated there is a relationship within the data okay so the sound signal is not a white noise if it was a white noise you will not make out any you know it is a correlated signal that without even knowing signal processing you can appreciate that a white noise will be just what you probably hear when you switch on the radio you hear that you know color noise which probably is sound realization of the white noise now the next question that I want to ask is if I have two different sequences are they correlated okay if there are two different time series what is a way to do that that is to cross correlation okay so again I can compute sample cross correlation sample cross correlation is using data you have data for one series you have data for the other series and then you want to compute cross correlation for then we normally develop this normalized major which is divided by you know variance of each one of them okay so if you see here this is series V this is series W okay you normalize this cross correlation cross covariance using these two signal variances that is normalization because it is easier to view the signal and again you can show that cross correlation can never exceed plus or minus one so that is a fundamental result and I am not going to prove this you will have to I mean this is just you know beginners introduction to this vast area the question again you can ask is how do you judge whether cross correlation is small enough see I have to make a call on whether two series are correlated with each other or not is this a cause and is this a effect I want to know that now again you have to develop a confidence interval and same result holds that each of these cross correlation function is you can view it as a random variable with distribution which is Gaussian 0 mean and 1 by root n for a white noise you will get and so what you actually do is that you do not know what is it for the colored noise okay you know what is it for the white noise so you can actually find out whether this white noise or not okay so by using this confidence interval you can say that this is not a white noise okay both of them are not white there is some correlation so again this is a some data taken from the net actually it comes if you see this one reference have given this Schumwe and Stoffer at the end of the notes Schumwe and Stoffer actually have given this data and on their book page of so this is some index which actually is a major of air pressure changes in air pressure related to sea surface temperature in the central Pacific now you probably have heard this Al Nino effect that is central Pacific region keeps warming with a cycle of 3 to 7 years and then that is blame for many things you know suddenly you see in newspaper that this year Mansoon is not good because this Al Nino is active or something like that so there is also data about fish population in central Pacific region collected by some government department and this is scale data it does not tell you exactly numbers it gives you between 0 and 100 there is some benchmark taken which is 100 and so the question is forming of all the changes in the pressure and temperature in the Pacific region does it have any correlation with the fish population okay. So the way to do this is to find out cross correlation between these two series okay now these are the two series this is first one is the southern oscillation index and the other one is this is a data taken from 1950 to 1985 and the second one is also 1950 to 1985 this is monthly data okay fish population every month okay I do not know how they have done scaling this is scale data but right now we can look at it as a scale data available to you they may not want to publish the true numbers okay so typically many times data when it is made available it is made available as scale data so 0 may not mean the fish become 0 it might mean it becomes low and then there is some high okay. So now if I look at auto correlation this is a periodic data and you want to see what is the repeating you know what is correlated is what in time within the data itself. So first I am going to look at SOI and also I am going to look at the southern oscillation index and also the fish population data you can see that the first one shows a nice periodic behavior okay with a period of 12 so there is a positive correlation with for time points which are 12 months apart and there is a negative correlation between time points which are 6 months apart. So this is these 2 points are 6 months apart they are negatively correlated while these 2 points are positively correlated that 12 months apart okay so that is what that is what so what is happening now has a correlation with what will happen after 12 months okay or vice versa what is happening now is correlated to what happened 12 months back okay. So more detailed models you have to use something else we will come to that this at least tells you that to there is auto correlation within the data okay this is not a white noise this is not complete kachara in the data it has some signal the same thing is true about the fish population data again it shows the periodicity the periodicity slightly different than there seems to be some time lag between the 2 okay so now if you take cross correlation the cross correlation peaks at every 6 months interval which shows that the index measured at time 6 months back is related to the fish population now okay so if index is changing so you know this I can use to do some predictions okay I can use this idea to or I can use to develop a prediction model for this the way to do it is using transfer function models that we will learn later but right now we are just analyzing the 2 series and saying that there is some correlation there is some correlation between the fish population and this index okay and it seems to be lagged by 6 months that is all we know from this correlation analysis right now okay what is this exact correlation how to predict okay what will happen see you are interested in knowing what is going to be the fish population after 6 months because it some industry might depend on it so how to develop prediction models will come to that little later okay but this at least tells you that there is prima facie case for building a model that relates index with the fish population okay if this thing had come everything within these red bounds here everything had come within the red bounds then we do not know we cannot say whether there is correlation or not and then we cannot develop a model between these 2 variables okay see these are black box models you know seemingly you know the fish population and temperature you know we do not know the physics that correlates this with the fish population we are not getting into the physics we are going to develop a black box model which just correlates you know SOI with fish population okay and this model is and these kind of models keep developing for control all the time okay transfer function models that we are going to develop are going to be this kind okay we know that this is a cause and this is the effect what is the difference equation that relates to that question we will ask later okay let us get back to our data that we were looking at okay this was model for the 2 tank system which we developed output error model we developed and then we had this question why did we start all this business of stochastic processes because we got this we got this series okay this was vk vk was everything that is not explained by inputs okay we got a model this blue is the model and plus plus plus are the data points and there is a difference and the difference is plotted here with this blue line okay and then we wanted to check whether there is any signal left there is some something relevant left in this okay so what is to be done first check whether auto correlated if this auto correlated that is the first question I should ask okay the second question I can ask is that see this model which I have developed is between y and u suppose some effect of u is left in this some effect of u is left in the residuals okay then the residual and u will be correlated my order I have chosen second order model second order could be wrong maybe I should go for third order some effect is not getting captured and that signal is left into this I want to extract everything that is okay so I am going to do two things one is auto correlation auto correlation for vk and cross correlation cross correlation between input u and vk okay everyone is clear about this okay so this is what you get if you use a MATLAB as a function auto correlation function and you can use that ACF after I finish this set of this I will give you demo of the toolbox I think partly professor Bharti has given you some demo but I will complete that task well all the tools that we are talking about are there in MATLAB or PSYLAB if you do not have MATLAB you can use PSYLAB in a public domain tool all the tools are available you should know how to use them that is the main thing you should know the fundamentals the theory and the theory is fairly complex you should try to develop an understanding otherwise you know you end up using it without knowing what is inside and then there is a big problem so the question is is there something in this vk now you can see here clearly this signal is auto correlated is a very strong auto correlation with the past in fact even with last 20 samples it is not over it might be there for last many many samples so there is auto correlation which is strong positive auto correlation cross correlation does not seem to be there so second order model seems to be okay I am not going to gain too much by going to third order model okay I will come to an example where actually I will choose a second order model and it will not be sufficient you will see cross correlation between residuals and you and then you will say my model order is wrong I will come to an example in this case some of it has worked out second order see we started by saying I wanted to develop a second order model a third order model a fourth order model I will first develop the simplest model second order model if it works why should I go to the third order well again I am going to give you a very sketchy introduction to fairly complex idea of spectrum of a signal okay it is fine in this course if you just get some kind of a working knowledge and not deep understanding deeper understanding of this will take time so well we are going to define what is called as the power spectrum of the signal vk okay power spectrum is defined as a function of frequency omega okay right now just accept this okay and try to get working idea as to because if I give a signal to matlab it will give me spectrum try to understand how to interpret the spectrum okay how it is a transform and then the way it works those of you who are electrical engineers and have worked with signal conditioning they would be comfortable with the spectrum idea so others who are from mechanical chemical might find it a little difficult but doing time series analysis and modeling we cannot escape this idea of spectrum so we define power spectrum of a signal as see look here this is infinite sum going from tau – infinity to infinity or v tau these are v tau are nothing but autocorrelations okay within the signal and this is e to the power – j omega t okay so this is actually a Fourier transform it actually represents a Fourier transform of the autocorverance function okay that is the interpretation of this it helps you to transform you to view the signal in terms of the you know signal power as a function of frequency we are actually transforming from time domain to frequency domain why we do why we do Nyquist plot and you know because we can get a different perspective of the signals or the system in frequency domain and you can do some analysis in the frequency domain okay so here given a signal okay what is the see we saw this signal here this signal you know I would like to know at different frequencies what is the power of the you know what is power of the signal at different frequencies okay what is the is this makes sense power of the signal at different frequencies frequency as in the way you define frequency per month not per second it will be per month so I can take a transform and then you can define a inverse transform right now you know let us keep the transform understanding at this one slide and move on to interpreting the transform okay if I show you a transform of a certain signals then you will get some idea so the physical interpretation is analogy I can give you is to probability density function what happens in probability density function how do you find a probability between two points you are given a density you take an integral between those two points and you will get probability of event occurring between those two points right the same thing is here if you are given a power spectrum density you can take an integral between band omega 1 and omega 2 you can find out power of the signal in that particular see if you give me a raw signal I am not able to find out I am not able to analyze the frequency content of that signal what range of frequencies exist right this is of interest from a you know modeler point of view that what is the range of frequency in which the area under the spectral density band represents the signal power in the certain frequency band and total area is proportional to the variance of the signal okay this crude interpretation right now a simple interpretation right now is what you try to keep in mind and we move on from this so let us look at the white noise spectrum okay what will be the white noise spectrum see what is the variance of white noise what is autocorrelation function of white noise it is sigma square at lag 0 and it is 0 at all other lags okay so power spectrum of white noise it turns out to be just sigma square by 2 pi okay because it is 0 at all other lags it is 0 only at 0 it is non 0 only at 0 lag it is so when you are summing from minus infinity to infinity you will get only this particular term okay so actually power spectrum of white noise is constant okay so that is the reason why we call it has all frequencies white noise is a signal which has all the frequencies present okay when you the analogy is with the white light see white light has all the frequencies present what is there in the colored light right if you knock off some frequencies okay you will get colored light okay so how do you get a colored stochastic signal you take a white noise pass it through a filter what does what do you do when you create say green light from a white light what you do you have a filter okay you have a filter you pass white light through the filter you will get a green light on the other side okay here you take white noise signal pass it through a difference equation which will act as a filter you know that a difference equation or a differential equation can be viewed as a low pass filter high pass filter you have you have seen this when you studied your first course in control right when you draw like Bode plot right you know that this you know a first order transfer function will be like a low pass filter okay and then PID controller is like all pass filter and depending upon how you choose D so you have you know the same way here this is the I am plotting here the spectrum of white noise okay spectrum of white noise can be estimated from data if you give data to Matlab and ask to compute spectrum it will compute spectrum and plot it for you you can see that white noise ideal spectrum should be this okay I have taken a white noise with variance 1 okay so the ideal spectrum should be this is plotted on the log plot okay so it is showing you 0 here and estimate is hovering around 1 see this blue line is the estimate of the spectrum okay it is hovering around 1 okay so the realization which I got is almost like a white noise because it has all the frequencies it has power at all the frequencies see this is amplitude this is power and this is frequency frequencies between 0 to 1 okay and you will wonder what is this 1 in discrete time systems you always plot between 0 to 1 where 1 is the normalized frequency okay and normalized with respect to this omega n omega n is called as a Nyquist frequency and this is defined as pi by t okay t here is the sampling period okay so here this 1 means frequency to pi by omega divided by pi by t okay it is normalized with this reference to it is omega by omega n what is omega n pi by t okay so the spectrum if you ask Matlab to plot spectrum it will always give you this normalized frequency spectrum okay and this tells you what is the power at different frequencies if I show you a colored noise signal then you will realize that what is the difference is just keep this figure in mind okay. No the in digital control these spectrum will repeat okay since it repeats we only plot the first normalization comes I think in that integral let me go back and check now this is power spectrum of autoregressive process I have created an autoregressive process vk is equal to 0.5 vk-1 and ek is a white noise okay whatever white noise I took here same white noise I have used here it is 0 mean white noise with sigma square equal to 1 okay and this is the autoregressive process this is like a first order filter first order difference equation it is a low pass filter it only allows low frequencies to pass through and higher frequencies are the signal and higher frequencies is cut off okay you can see here in the power spectrum that the spectrum is high at low frequencies spectrum becomes small at high frequencies okay the spectrum becomes small at high frequencies so this is how a colored noise will look as against the white noise white noise has all the frequencies okay has almost equal power at all the frequencies whereas the colored noise has high power at some frequencies low power at some frequencies so analogy is with these terminology I have to introduce because we keep using this okay we are not again as I said in this course we are not going to by do hand calculation of a spectrum but you know this is a difficult idea and then we have to at least have some idea of what is a spectrum okay well I am trying to compress a huge course into few lectures and that is why I have to go little fast well power spectrum you know you can think about finding of a power spectrum for the speech signal at which frequencies there is more power which frequencies there is low power okay maybe when you are transmitting the signal you can decide to transmit only that part which is at you know which has significant power you can knock off the part which has low power and then you will get almost the signal that you know that you here so that is an important aspect in signal processing and so right now just get this qualitative understanding of white noise and colored noise that is enough will move on to the modeling so this brings to end the prelude or background material which I wanted to teach on stochastic processes okay it is not possible that this two three hours of lectures will give you understanding of this area for me personally it has taken years to understand what each thing means okay so but then you know you can start using this terms you can start using matlab programs keeping these slides in the background slowly we learn we should not too much worry about you know in the beginning you do not get full meaning of what it is you should have attitude of a child where a child learns a language without being scared of you will use some seven year child will come and say what is your responsibility he does not understand what is the meaning of responsibility but he will use the word anyway so you start using the words and slowly the meaning will percolate okay so now after this abstract background which is needed language which is which I need now I am going to get into the practical problem so now I want to develop a model we started with this right y is equal to gq into uk plus vk we developed an output error model we never attempted to model vk okay now I want to model vk using this idea of stochastic processes autocorrelation cross correlation okay so this is going to my deterministic component okay deterministic in the sense u is known to me okay everything that is known to me will be you know in this residue okay so this residue will contain two things unmeasure disturbances measurement noise in fact it will also have approximation errors because the real process will not be linear you are developing a linear model so this is combination of everything that is not known not known to you okay now information even though you are not measuring the disturbances its effect is present in y right its effect is present in y and if you develop this kind of a model its effect is present in v we saw that vk is autocorrelated so now there is a hope to uncover a model from this vk okay so what is an obvious choice of structure okay an obvious size of structure is yk is some function of past u and also past y because where is the information about disturbances hidden it is there in y itself right effect of disturbances is present in y so I want to use that information develop a model uncover it and then use it for control okay now I have this little term coming here ek okay I am going to develop this model f is some function initially I will take linear functions and in this course we are going to stick to linear functions nonlinear functions would be part of an advance course not really in this course when will I know my model is correct I will stop only when this ek is a white noise why white noise in the white noise there is no autocorrelation white noise is like complete kachara okay it is complete dirt you can throw it there is nothing left no signal left in white noise okay so I will develop this model till ek becomes a white noise okay I will do this for a particular case and I will show you that you know you have to go on increasing the model order till ek becomes white noise okay we will see one this specific case I am going to go back to the same data I am going to call this okay I can propose a linear model which is of this form can everyone see this model okay it says that yk is a function of a1 yk-1 linear difference equation model simple linear difference equation model okay this is different from output error model why it is different in output error model you had here xk xk-1 we said that yk is xk-vk here I am directly using yk I am saying current measurement okay output error model we had two things we had xk and let me just go back here and remind you okay see my model output error model my output error model was xk is equal to minus a1 xk-1 plus b1 uk-1 and yk is equal to xk-vk now this model is fundamentally different from writing yk as minus a1 or let us call it a1 yk-1 plus b1 or beta1 uk-1 these two models are fundamentally different because in one case we are working with x which is effect of u alone okay and in this case we are working with y directly y is measured okay x can never be measured okay x is a combined effect of vk and sorry y is a combined effect of xk and vk okay y is a combined effect of xk and vk y can be measured so this model is fundamentally different they look similar but there is a big big difference okay okay now how many how many you know here you see that I am taking yk-1 yk-2 yk-3 how many such past values I should take yeah no no so I want to develop this model in such a way that e of k will become right I do not know what order to choose no no but it depends upon how would you choose the model order it is not obvious that always becomes right I will give an example okay so how many past outputs I should include okay now here because you are modeling noise together with deterministic component you do not know how many past why is that important what is the autocorrelation we do not know right now okay so how much how many past we should include we will choose model order in such a way that e k becomes a white noise okay so now I will show you an exercise in which I will start with model order 2 3 4 5 6 you see that till you go to 6th model order you do not get white noise okay that is because now you are trying to capture deterministic dynamics together with stochastic dynamics both are captured together okay how do you develop this model okay let us first understand how to develop this model given the data this model development is very very easy you can even write a simple program in matlab to do this have you done linear v squares well we have done in our course on numerical methods but others probably have done v squares method at some point if you are not done I am going to repeat it I am going to do it here in the nodes so hope you have taken print out of the new nodes because I have done lot of rearrangement let us look at the second order model okay what is it there with me I have data of y I have data of y with me I have data of u with me okay so I have collected y data and u data perturbation data let us see how to develop a second order model okay now for this tank system we know that there is a unit time delay so that I have included here so my model becomes y k is a 1 x y k – 1 previous value of the measurement previous 2 values previous and then u k – 2 and u k – 3 that is because of 1 unit time delay in addition to the basic time delay so this is my model okay second order model I want to estimate a 1 a 2 b 1 b 2 from data I have data for y and u okay great thing about this model is that y is known u is known estimating a 1 a 2 b 1 b 2 is going to be very very easy how many parameters are there 4 parameters okay 4 unknowns how many equations you need 4 equations what how many unknowns are there in this 4 unknowns really or 5 unknowns which is the 5th unknown ek you do not know what is ek so there is a trouble you cannot just use 4 equations okay so now let us start writing the equation my first equation will be y 3 I have started data from I have data which is index from u 0 u 1 u 2 u 3 y 0 y 1 y 2 y 3 okay so my first equation that I can write is for time 3 do you agree with this okay because my data in u it starts with u 0 I do not have data for u minus 1 that is some 0 point so my first equation is going to be this okay there are unknowns a 1 a 2 b 1 b 2 e 3 these are 5 unknowns okay my next equation is y 4 this has a 1 a 2 b 1 b 2 but e 4 has cropped up okay and likewise if I go on writing these equations you know how many equations I will get I have n capital N data points I will get sorry I have capital N plus 1 data point because 0 0 is considered so I will get n minus 3 n minus 3 equations you will get how many unknowns are there no all these are unknowns all these are unknowns so how many unknowns are there n minus 3 plus 4 there are n minus 3 equations and there are n minus 3 plus 4 unknowns so number of unknowns is much more or is 4 unknowns are more than the number of equations okay so you have to do some trick to come up with a solution okay those are estimates no because no what you say is right I think there is a typo here moment I put in e this should not be y hat this should be y 4 I agree this is a typo here it should be y 4 and it should be sorry it should be y 4 not y hat 4 if I remove e it will be y hat yeah thanks for the catching the okay now what I have done is I have put these equations into matrix form some of you have done these squares this form would be familiar okay I have just put this set of equations into standard matrix form y here capital y here is a vector of all y is stacked okay this is a matrix the first row here will be y 1 oh it should be y 2 y 1 so there is a again a slight typo here it should be y 2 y 1 if you go back here should be y 2 y 1 u 1 u 0 okay so I will correct this just correct it on your notes right now it should be y 2 y 1 so you have you get this it should be y 2 y 1 not okay so I have this 4 unknowns a 1 a 2 a 3 a 4 I have these additional unknowns e 3 to en okay I have these additional unknowns and all of them have to be determined okay I am going to write this as a 1 matrix equation matrix y okay is equal to this omega matrix into theta plus e is vector of all errors okay now I want to estimate theta okay eventually I also want to estimate e but e are the errors right e are the errors so I am going to estimate theta such that some of the square of errors is minimized these square estimation right all of you are aware of these square estimation okay so this is a linear in parameter model so very nice model and this model I can estimate parameters analytically I can solve the optimization problem analytically how to solve the optimization problem there is an error 2 and 3 should be 2 and 3 yeah I will correct this this matrix is this matrix that one index needs to be corrected yeah if you have it print out you just correct it right now I will put a corrected version online now these square estimation problem what I want to do is I want to estimate some of the square of errors which turns out to be nothing but e transpose e here okay and then you know e transpose e is nothing but y-omega theta transpose y-omega this problem can be solved analytically what is the necessary condition for optimality the derivative of the objective function objective function is some of the square of errors that should be equal to 0 okay so I am finding out this small psi here is my objective function e transpose e I am setting derivatives of this with respect to theta theta is nothing but a1 a2 b1 b2 0 this solution can be found analytically so if you actually this is the intermediate step you take the gradient and set it equal to 0 if you set it equal to 0 you get this least square estimate okay this particular estimate is the least square estimate of a1 a2 b1 b2 okay obtained from the data which you have collected okay well what is the sufficient condition for optimality the second derivative should be positive definite ACN should be positive definite if I find out the ACN it turns out to be this matrix omega transpose omega this matrix is it always positive definite if this matrix is it has rank equal to 4 in this particular case it will always be positive definite think about it this site omega transpose omega will always be a positive definite matrix so which means you have got the global minimum in this particular case in fact you reach the global minimum analytically ARX model what we call it as ARX model very very easy to compute okay so if I do this on this data which I have from the full time I will get this model I will get this model parameters okay now the question comes is that I got this model once I got this model see I can go back and use the definition of e to be y-omega theta I can substitute here least square estimate I can get an estimate of e find out whether it is a white noise or not if it is not a white noise my model is not correct I should go back and change the order okay so that is my next thing which I am going to do so I got this model okay I got these estimates of the model and look at the model looks very good you know see I will just go back and check here I will just suppose this with the OE model that we got OE model vk was like this right you are going from 0 to 0.15 now and then there was a gap between the prediction and measurement okay come back here second order ARX model wow okay it is just the model and the predictions and the measurements are sitting on the top of each other you cannot see the difference can you see here blue line and plus plus you cannot see the difference the error is very very small okay now the question is this a white noise visually it looks like a white noise unfortunately it is not a white noise okay it turns out that this is not a white noise so my model residuals so this on if you just look at the two diagrams it is better than the OE model you know it has closed that small gap which existed okay so first check is I will find out the residuals residuals are y measured minus omega matrix into estimate which is same as y minus y hat what is y hat y estimated okay then I will check for autocorrelation function if autocorrelation function shows that it is not a white noise my model is not good I have to change the model okay then what should I check cross correlation between u and ek okay so I want to check cross correlation between u and ek this is it this is the autocorrelation function you can see here this this autocorrelation value peaks out so this is not a white noise here see the autocorrelation function this guy here is outside the bound so there is a autocorrelation negative autocorrelation between ek and ek minus 1 which means ek is not a white noise okay which means ek is not a white noise what about cross correlation ek and uk are correlated so some effect of uk is still left in ek your model residuals is not completely white you cannot accept this model even though visually it looks very good you know the match looks very good but I do not accept this model okay so what I am going to do is I am going to go on developing the models so this is I have developed a model which is second order third order fourth order fifth order sixth order and I have just sorted here some of the square of errors okay you can see that the objective function value of the objective function some of the square of errors go on decreasing at once I if I develop a model of order 6 6 legs yk minus 1 yk minus 2 yk minus 3 up to yk minus 6 uk minus 1 uk minus 2 up to uk minus 6 if I develop this model up to order 6 then the noise becomes white then I have removed everything from the residuals okay so here you can see that it is almost white okay actually you should go on developing a model with higher and higher order but there are some issues I will talk about those issues but it is not exactly white but it is almost white there is there seems to be some small correlation left with yk and uk sorry uk and uk but I am willing to live with this model yeah what will error will increase now that there are issues why why cannot we go on developing a model of higher and higher order I am going to talk about those issues now there are fundamental issues as to so now there is a problem you know this seems to give me a model in which the gap is closed and so all the noise is modeled how the noise is modeled I will come to that I will come to that a little later but before that I want to analyze the parameters estimates of the parameters okay and then I want to give you some insights into the behavior of the estimated model so ARX model is a very popular model in the industry it is very often used okay the trouble is you have to get a good ARX model you have to use large number of parameters and why large number of parameters is a trouble okay I will come to that now that is MATLAB which means 6 lag in u 6 lag in y and 2 is a time delay time delay of 2 we started with uk-2 know so default time delay for any model is 1 here there is one more lag so 2 so this actually ARX 6 6 2 is MATLAB command which I have used here okay so now this ek here is a white noise okay there is no autocorrelation in this ek almost okay and there is no much correlation left between ek and uk so I can accept this model if you want you can go little further I have stopped at 6th order maybe you can go up to 8th order but beyond that okay so these are my model coefficients now model here consists of 2 things one is this A polynomial B polynomial this MATLAB will pop up you know you just say ARX I think also Bhartya showed you this right using this ARX model you do not remember now because probably the theory was not covered okay so MATLAB will pop up this model give data it will pop up this model okay it is as easy as that but here the model consists of 2 things one is this transfer function A and B okay it also tells you about this ek okay and soon I will show that this ek is also as important to us as this model okay so I have also listed here if you notice I have listed here mean of ek is almost 0 not exactly 0 close to 0 10 to the power – 3 okay and this is the variance so this is like a 0 mean noise white noise almost white noise and I know its variance I can estimate it variance from ek e transpose e square root of that divided by n that formula we can use and get variance of this signal okay this practically a 0 mean white noise signal and what is it what is the role that this signal is playing in terms of you know noise modeling okay I think let me go to that first and then come back to this logically I will keep few slides and then come back to these slides okay so my ARX model is like this is everyone with me on this my ARX model is my ARX model is like this okay where I made sure that ek is a white noise okay to develop the 6th order model which means we use uk – 1 uk – 2 up to uk – 6 yk – 1 yk – 2 up to yk – 6 and we got those polynomials in q aq bq you got right I just showed you the date for this particular data which we have okay now I am going to rewrite this model like this is there any doubt with what I have done just check can you see this slide is this clear what I have done I have just taken q transform okay and then written it as a transfer function okay yk what is this part this is my gu this is my gu okay this is my model for noise earlier I had written vk here okay earlier I had written vk now I am writing 1 upon a a is the polynomial that you got from here right into ek okay so this quantity 1 upon aq into ek is actually my noise model okay this is my noise model so I have modeled a noise I have modeled a noise as a transfer function which is driven by a white noise do you see this if I write it if I write this model like this my noise here this is my noise my noise here is actually modeled as ek passing through 1 upon aq okay this is my noise model so this is my vk okay what we made sure because ek is a white noise sequence you agree with me okay so implicitly without realizing we have constructed a noise model here which can be distilled out only when you go to only when you go to q domain okay when you write it in the shift operator format you can distill out what is the noise model what is the deterministic model this part vq by aq is the deterministic model okay and 1 by aq into ek is the stochastic model earlier we called this as vk okay this is my stochastic model so this is the model for unknown effects unknown components unknown disturbance okay so this model is driven by 2 inputs what is the first input uk uk is the known signal to you uk is the wall position that you changed okay it is driven by another hypothetical signal called ek is not a real signal ek is not a real signal ek is a white noise source is an idealized white noise source which is driving the transfer function okay so let me summarize this like this so my model can be written as 2 parts okay my model can be written as 2 parts vk equal to gq into uk what is g effect of deterministic component okay g is my transfer function with respect to the deterministic component what is h for a rx model it turns out to be 1 by a for a rx model it turns out to be 1 by a okay so this is my noise model okay the noise model is consist of a transfer function and a white noise source white noise source is hypothetical this hypothetical white noise source is driving is actually driving the assume or we model that unknown component is as if a white noise is passing through a filter what is this filter 1 upon aq filter is 1 upon aq that is a filter okay so the trick to model unmeasure disturbances is to model it as a white noise source which is passing through a difference equation okay that is the basic idea using time series modeling this particular idea to crystallize this idea has taken believe me centuries it is not at all so easy to come up with because you are trying to model something for which you do not know what real input is you just have its effect present in the data and you still want to uncover a model okay very very difficult so you have constructed a hypothetical signal called white noise which is passing through a transfer function which gives you same effect as the unknown disturbances there is no real source called white noise anywhere okay it is a model and it works it works quite well in predicting the unmeasure disturbances why do I write uk-d so that delay about delay no no it will represent a value of ukd k-d instant in the past uk-1 is 1 instant in the past uk-2 is 2 instant in the past no no the meaning of writing q-d here or uk-d is that a value a past value of u has effect on what is happening today see for example you know let us take a situation where you know suppose I teach something today okay you are understanding up to two days okay then how will you write a model for that you will say that what I know today is actually effect of what was taught two days by not what is being taught today so what I am teaching today is to understand after two days because there is a delay of two okay so that is what is being that is what is being quantified here through the time delay this term d-d so the past what is the meaning of delay in the measurement delay in the measurement is what you observe now okay actually was something that happened in the past okay is not what is what is the see it is a delay in the measurement okay so which means the temperature that you see now okay is actually what has happened you know sometime in the past in the system that is the meaning of delayed measurement so both of them can be represented through this model not uk-1 no if uk-1 mean there is unit delay only delay of one plus d no see plus d okay you understand one basic thing here see so this is present so when I am writing k-1 so I am at instant k k-2 k-3 these are all in future okay so k-1 k-2 k-3 so this is k-d in general d samples in the past okay I cannot have a model which says you will never have a model which says that what is happening now is a function of what will happen in future delay means what is happening now see in a discrete time system there is always unit delay so if you take a input if you introduce a input here its effect can be seen only here that minimum one delay is always there sometimes there is more delay which means what you what you do here its effect might be seen here or equivalently what you do here let us say there is a delay of 2 what you do here its effect is seen here what you do here its effect will be seen here okay this is related to this this is related to this this is related to not 2 in future okay. So the delay is always in the past okay if you talk about something into future future will not have effect on the present no future will not have effect on the present so the past will not effect on the present that model you can develop future having effect on the present is not something that you can do, so k here just remember whenever we are doing this k is always current time, k-1 is 1 in the past, k-2 is 2 in the past, am I answering your question or we can talk about it later after the class okay. So basically what has happened is that you know we have got a model which is linear in parameter model and effect of unmajor disturbances has got modeled as a transfer function which is driven by a white noise, we could obtain the values of this model using linear v-squares because ARX model you know y and u are known in OE model if you remember you have to do nonlinear optimization x was not known, you have to guess x you did not know x you did not know v you had all kinds of problems and you did not know parameters, no delay estimation is typically done a priori there are methods to do delay estimation, simplest way is you give a step change and see when the output start changing you can estimate delay from that okay, so you have to do lot of studies to estimate delays it is not that, what is the problem with this model you need lot of data in the past, so let me uncover this noise model and show you what it is actually it will turn out to be autoregressive process okay, without saying it actually I have actually modeled an autoregressive process how I am just multiplying this, just consider a scenario where u is 0, if u is 0 permanently 0 what remains is only noise okay, earlier this noise we had called it vk, so I have chosen to call it vk here okay, vk is equal to this is my noise model vk is equal to 1 by aq into ek what is this model it is an autoregressive model, if you just expand this you get this if I expand this what actually I have got is an autoregressive model okay, so now autoregression is able to help me construct a model for autoregression is a nice thing it is a stationary process okay, I can develop a model for a random signal which is fluctuating okay, it is auto correlated through this autoregressive model okay and I was able to get a1, a2, a3, a6 I was able to uncover the coefficients okay, so now I can talk about that signal just using this model what actually you are doing, you are representing a stochastic signal which has you do not know what the source of it is through a model which is a difference equation model okay, it is driven by a white noise, so this white noise 0 mean white noise with its variance is equally important here model consist of a1 to an plus white noise and its variance you cannot separate the two okay, so even though this white noise does not have anything left in it is useful actually it is used in modeling the noise okay, just understand this well I can play with it now once I have this model in q domain if aq you know if it is if the poles are inside the unit circle then you can do a long division and then get this infinite sum and then I can write this model okay, so what I want to show here is that we talked about two processes right moving average process and autoregressive process I did introduce them without purpose I talked about them because they are useful in modeling stochastic signals okay very simple models now and they are inter convertible all the time time to tell you is that one and other are inter convertible see here if I 1 upon a can be expanded as a you just do long division okay, you can do polynomial division 1 upon you know maybe I can give you as an exercise you can do this division and see. So I can write 1 upon aq as 1 plus hq1 plus h2q2 and so on and then that means vk is some function of past ek alone okay this h here you will see that it will go on reducing in values h will go to 0 okay if the poles are inside the unit circle and then you can truncate this series so another way of constructing a model is moving average process okay I can develop an autoregressive model I can develop an AR model okay that is autoregressive model I can do the MA model moving average model okay these are two different ways of capturing or developing a models for noise models okay well I can combine these two and develop what is called as Arama model I will come to that little later but is everyone clear about the abstraction that I have come up with for noise modeling okay is this transition I started with this okay I said this is my ARX model ARX model I am going to abstract as deterministic component and stochastic component this stochastic component was 1 upon a then I wrote vk as 1 upon aq into ek and showed you that this is nothing but autoregressive process autoregressive process by driven by white noise this signal we have seen earlier right this was a in fact why is this a colored noise or a white noise it is a colored noise I showed you an example of autoregressive process which is colored noise spectrum was you know yeah it was high at low frequencies low at high frequencies this is a colored noise okay now I have a model for the colored noise obtained directly from data I have a model for the colored noise obtained directly from data and the next thing which I am going to say here is that this is this can be converted to moving average process those two model forms autoregressive and moving average are just inter convertible forms you can go from one form to the other form this form just like you can go from discrete to continuous continuous to discrete same thing holds here okay just a very very quick thing about one problem I was told is having difficulty in solving from going from discrete time system to continuous time system problem number 6 okay some of you are having difficulties I just want to point out one thing here is just look at this 5 matrix and a matrix the same Eigen vectors this is the clue to the problem and Eigen values of 5 and Eigen values of a are related by e to the power lambda capital T if you know sampling time you can see you start with 5 you first find out the Eigen vectors then you will get this psi matrix okay you will get psi matrix once you have psi matrix you can write psi inverse okay you will also get this matrix e to the power lambda t from this getting lambda matrix is not difficult because the relationship is e to the power lambda i t is this is the relationship that is if lambda is the Eigen value e to the power lambda t is the Eigen value of this matrix look at this slide 72 okay slide 72 is the solution for that particular problem and the other part can be uncovered from getting b matrix is yeah look at this equation gamma matrix is nothing but 5-i x a inverse b so if you know gamma if you know phi if you know i if you know a you can recover b okay just use this so this is slide what 39 and 72 as the clue for problem 6.