So in this video, we will be answering the question, why are states based models something of interest?
Let's start with what the main points are and then the rest of this video will be expanding on these
points.
OK, so one important application of states based models is that they allow us to model a wide variety
of real world systems.
These can be electrical systems, mechanical systems, economic systems and even biological systems.
So basically, anything you care to model can likely be models.
Another interesting point is that states based models can be used for both continuous time and discrete
time systems.
In this video, we'll look at a continuous time system just for fun, even though we don't normally
see such examples in machine learning and data science.
The third point, which is pretty important, is that this representation is the basis for the theory
of how to control these systems.
That is, how can we make these systems do what we want them to do or how can we put the system into
a state of our choice?
OK, so let's start with one surprising fact, which is that states based models can be applied in both
discrete time and continuous time systems, continuous time systems are often more realistic because
they correspond to the laws of physics.
But eventually you need to program these systems into a computer which requires a discrete time representation.
The most common type of states based model is the linear states based model, which looks like this.
The discrete time version says that the state vector at time t depends on the previous state vector
at time T minus one and some control input vector U of T.
The relationship between these vectors is controlled by the matrices and B the output vector Y of T
depends on the state vector and the control input through the matrices C and D..
Now don't worry if this seems a bit abstract, since we'll do an example very shortly.
So here's a linear states based model in continuous time.
Basically, it has the same format as the discrete time version, except that on the left side we have
a time derivative instead of just the next time step.
And again, continuous time systems are useful because they can represent real physical laws of nature.
So any analysis we do on these systems is based on real physics.
This is opposed to discrete time systems which are useful for building computer programs.
OK, so as mentioned earlier, although these equations may seem a bit abstract, they are also very
general.
What we discuss in this lecture can really be applied to any field, whether that's electrical systems,
mechanical systems, economic policy and biological systems.
So, for example, you can model your physiology and determine how to administer a drug to keep your
body in an optimal state.
For this video, we'll be doing a simple example, which only requires a bit of high school physics.
So hopefully it makes sense.
And you recognize these concepts.
OK, so one of the most popular systems we study in physics is the mass in the spring.
So let's suppose we have a mass attached to a spring which is attached to a wall on the other ends.
Now, as you recall, our goal in such a system is to determine all of the forces that can act on each
mass.
In this case, we only have one mass.
So one force on this mass is the input force you, which is the force that we get to apply.
So you can imagine this like being the output of your computer program that gets to control how much
force is applied to the mass.
Now, this is not the only force applied to the mass.
The spring also applies a force whenever the spring is not in a neutral position.
So let's create a variable X, which represents how far away the mass is from its neutral position.
Thus, X equals zero represents no tension on the spring will assume that the positive direction is
left to right, so that when the mass is to the right of this neutral position, then X is positive.
In this case, the force from the spring is minus.
Kayak's work is what we call the spring constant.
This force is a minus sign because when X is positive, the spring pulls the mask to the left.
Alternatively, we can just write X with an arrow going to the left.
Now there is one more force we're going to consider, which is friction.
So let's assume that the mass sits on a table and this friction or damping force is proportional to
the velocity.
We'll call this damping coefficient B, so the force due to friction is minus B times the velocity or
B times X.
This has a negative side because again, if the mass is moving in the direction, this force will be
in the minus direction.
Also, recall that we use a dot as another way of writing the time derivative.
OK, so the next step is to recall Newton's second law of motion, basically, the force on an object
is equal to its mass times, its acceleration.
So on the left side, we have M times X double again.
Since the dot represents the time derivative X double dot represents acceleration.
On the right side, we have the sum of all the forces on the mass.
So that's U minus Kayak's minus Beckstein.
OK, so this is an equation which represents our system.
The next step is to consider how to convert this into space form.
So the trick in these kinds of problems is how we define the state in this case, we're going to define
a new vector containing X and X dot.
So this might be a bit confusing since I've used X from multiple things.
So for the purpose of this derivation only, I'm going to use an underscore to denote the X Factor,
which is the state it contains X and X die for convenience.
We can also think of these as X, one and X to simply the components of the state.
Now one thing we can see right away is that X two is equal to X one died.
The next thing to do is to express our original system in terms of X one, an X two.
When we do that, we get M times X two dot equals U minus one, minus two.
We can also simplify this so that we only have X to dot on the left side.
Basically we just divide everything by.
Now, as you recall, with a state based model, what we would like to have is the derivatives on the
left and the regular variables on the right.
So let's see what happens if we try to put these equations into that format.
Of course, it should be clear that this is a matrix equation on the left side, we have X one dot next
to die, which is the derivative of our state vector.
On the right side, we have some matrix A multiplied by a state vector plus some matrix B multiplied
by our input.
You you can think of you as a one by one matrix.
So as you can see, both Matrices A and B are determined by actual physical quantities.
Now, in the real world, it's often the case that not every state variable can be observed.
So, for example, we might know the position, but not the velocity in this case.
We let the variable y represent our observation, which is just the matrix C times the state vector
X plus another Matrix D times the input.
You clearly this is a pretty trivial addition to what we had before, but we now have a full linear
states based representation.
So this states based representation looks pretty simple, but why do we actually care about this?
Well, the fact is there is a lot we can do with this now.
It requires some linear algebra, but the potential is there.
For example, by looking at the eigenvalues of A, we can determine whether or not the system is stable.
The most important point is there with this framework, we can build programs to control these systems.
So not only can we forecast the next state of the system, given where it is now, we can actually decide
where we want it to go.
What we would like to do is find some matrix K such that if we set the input you to be K times the observation
Y, we will control the system in some desired way.
This makes sense since what we want to do, which is you should be computed from what we observe, which
is why of course the challenges, how do we actually find K.
Now, one interesting fact is that one of the most popular time series models called Arima came from
a book by Box and Jenkins.
This book is really how Arima became as popular as it is today.
The title of this book is Time series Analysis, Forecasting and Control.
So you can see that even at the origin of Arima, it was clear that forecasting is not the only interesting
thing you can do.
Controlling systems, which falls under control theory was always part of this field.
Now, in the real world, we know that systems have noise.
So what happens when we add noise to our linear states based model?
In these situations, we often want to answer the question, what is the state?
Given our observation?
One common example of this is why might represent sensor readings like the GPS on your car X, which
is the state might represent the true location of your car.
In this case, there is a popular algorithm called the Cowman Filter, which finds the optimal gas for
X.
And keep in mind, this is a sequential model.
So this optimal gas doesn't only depend on the current Y, it depends on all the previous Y's from time
one up to T using this model, we can also forecast the next states at times plus one or two, plus
two and so forth.
OK, so I hope this video helps you see why the states face representation is useful and how it can
be applied in different scenarios.
It really is a universal tool which is studied by both engineers and statisticians and can be applied
to pretty much any field, including biology, economics and business.
Thanks for listening and I'll see you in the next video.