# The moving average is depends on previous value or not?

In the pictures above, I understand the right side, e.g the v100 is depends on the previous one v99. The v99 is depends on the previous v98 … and so on.

However, in the picture above, left side, the hw hint, lets say the 1st equation, the Vdw[l] depends on the current itself Vdw[l] ? I thought the current one Vdw[l] depends on the previous one Vdw[l-1] which the 1st Vdw is all = 0.

Does the moving average depend on the previous value or current? Thank you!

Hey @sunson29,
The moving average depends on both the previous value (for instance v_{99}) and the current update (for instance \theta_{100}). The way the programming has been done is what I assume is tripping you up. Let’s understand it with a simple example:

Consider a variable x and \beta = 0.9. Let’s say that in the n^{th} iteration, x = 5. Now, in the (n+1)^{th} iteration, let’s say that the update value or \theta = 2. So, when we will perform the update, we will get the new value as 0.9 * 5 + (1 - 0.9) * 2. So, when we will write this in code, we will simply write this as \beta * x + (1 - \beta) * \theta. In simple words, in the next iteration, until x hasn’t been updated, it stores the previous value only, right? So, we use x on the left side (indicating the previous value), and once it has been computed, i.e., x on the right side indicates the updated value. I hope this helps.

Cheers,
Elemento

omg… that’s a silly question…

master, for this same question, I had another post, just yes or no question at the end, could you confirm my 4 lines of code there? thank you!

Hey @sunson29,
Please don’t call me as “master”, or for that fact, any other mentor here. We all are learners just like you. For future references, call me Elemento. As for your other query, let me take a look.

Cheers,
Elemento

got it. you are very humble ~~~