Skip to content Skip to navigation Skip to collection information

OpenStax-CNX

You are here: Home » Content » A First Course in Electrical and Computer Engineering » Filtering: Moving Averages

Navigation

Table of Contents

Lenses

What is a lens?

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

This content is ...

Endorsed by Endorsed (What does "Endorsed by" mean?)

This content has been endorsed by the organizations listed. Click each link for a list of all content endorsed by the organization.
  • IEEE-SPS

    This collection is included inLens: IEEE Signal Processing Society Lens
    By: IEEE Signal Processing Society

    Click the "IEEE-SPS" link to see all content they endorse.

  • College Open Textbooks display tagshide tags

    This collection is included inLens: Community College Open Textbook Collaborative
    By: CC Open Textbook Collaborative

    Comments:

    "Reviewer's Comments: 'I recommend this book as a "required primary textbook." This text attempts to lower the barriers for students that take courses such as Principles of Electrical Engineering, […]"

    Click the "College Open Textbooks" link to see all content they endorse.

    Click the tag icon tag icon to display tags associated with this content.

Affiliated with (What does "Affiliated with" mean?)

This content is either by members of the organizations listed or about topics related to the organizations listed. Click each link to see a list of all content affiliated with the organization.
  • Bookshare

    This collection is included inLens: Bookshare's Lens
    By: Bookshare - A Benetech Initiative

    Comments:

    "Accessible versions of this collection are available at Bookshare. DAISY and BRF provided."

    Click the "Bookshare" link to see all content affiliated with them.

  • NSF Partnership display tagshide tags

    This collection is included inLens: NSF Partnership in Signal Processing
    By: Sidney Burrus

    Click the "NSF Partnership" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

  • Featured Content display tagshide tags

    This collection is included inLens: Connexions Featured Content
    By: Connexions

    Comments:

    "A First Course in Electrical and Computer Engineering provides readers with a comprehensive, introductory look at the world of electrical engineering. It was originally written by Louis Scharf […]"

    Click the "Featured Content" link to see all content affiliated with them.

    Click the tag icon tag icon to display tags associated with this content.

Also in these lenses

  • UniqU content

    This collection is included inLens: UniqU's lens
    By: UniqU, LLC

    Click the "UniqU content" link to see all content selected in this lens.

  • Evowl

    This collection is included inLens: Rice LMS's Lens
    By: Rice LMS

    Comments:

    "Language: en"

    Click the "Evowl" link to see all content selected in this lens.

  • Lens for Engineering

    This module and collection are included inLens: Lens for Engineering
    By: Sidney Burrus

    Click the "Lens for Engineering" link to see all content selected in this lens.

Recently Viewed

This feature requires Javascript to be enabled.

Tags

(What is a tag?)

These tags come from the endorsement, affiliation, and other lenses that include this content.
 

Filtering: Moving Averages

Module by: Louis Scharf. E-mail the author

Note:

This module is part of the collection, A First Course in Electrical and Computer Engineering. The LaTeX source files for this collection were created using an optical character recognition technology, and because of this process there may be more errors than usual. Please contact us if you discover any errors.

Moving averages are generalizations of weighted averages. They are designed to “run along an input sequence, computing weighted averages as they go.” A typical moving average over N inputs takes the form

x n = k = 0 N - 1 w k u n - k = w 0 u n + w 1 u n - 1 + + w N - 1 u n - ( N - 1 ) . x n = k = 0 N - 1 w k u n - k = w 0 u n + w 1 u n - 1 + + w N - 1 u n - ( N - 1 ) .
(1)

The most current input, u n u n , is weighted by w 0 w 0 ; the next most current input, un-1un-1, is weighted by w 1 w 1 ; and so on. This weighting is illustrated in Figure 1. The sequence of weights, w 0 w 0 through wN-1wN-1, is called a “window,” a “weighting sequence,” or a “filter.” In the example illustrated in Figure 6.8, the current value u n u n is weighted more heavily than the least current value. This is typical (but not essential) because we usually want x n x n to reflect more of the recent past than the distant past.

Figure 1: Moving Average
This is a graph consisting of two curved lines that are horizontal in nature and several vertical lines which arise at from the x axis and end when they reach the curved line. The first curved line begins with an initial positive slope, but after reach the second vertical line takes an extremely negative slope and falls below the x axis. At about the seventh vertical line, the slop again turns positive and rise quickly at first and then plateaus. The other horizontal line begins around the third horizontal line and has a positive slope which gets more and more positive to it almost vertical by the time it ends. The intersection of the first horizontal and the third horizontal line is labeled u_n-(n-1). The intersection of the second horizontal line and the third vertical line is labeled w_N-1. The third line appears to be labeled below the x axis as N-1. The intersections of the final three vertical lines and the second horizontal line are labeled w_2, w_1, and w_0 from left to right.  The intersection of the second and third to last vertical lines and the first horizontal line are labeled U_n-1 and U_n respectively. The second and third from the left vertical line are labeled below the x axis as N-1 and n. The x axis line is labeled k.

Example 1

When the weights w0,w1,...,wN-1w0,w1,...,wN-1 are all equal to 1N1N, then the moving average x n x n is a “simple moving average”:

xn=1N[un+un-1++uN-1].xn=1N[un+un-1++uN-1].
(2)

This is the same as the simple average, but now the simple average moves along the sequence of inputs, averaging the N N most current values.

Exercise 1

Evaluate the moving average xn=k=0N-11Nun-kxn=k=0N-11Nun-k for the inputs

  1. (a) un=0,n<0u,n0;un=0,n<0u,n0;
  2. (b) un=0,n0n,n>0.un=0,n0n,n>0.

Interpret your findings.

Exercise 2

Evaluate the simple moving average xn=k=0N-11Nun-kxn=k=0N-11Nun-k when u n u n is the sequence

u n = 0 , n < 0 a n , n 0 . u n = 0 , n < 0 a n , n 0 .
(3)

Interpret your result.

Example 2

When the weights w n w n equal w0anw0an for n=0,1,...,N-1n=0,1,...,N-1, then the moving average x n x n takes the form

xn=w0k=0N-1akun-kxn=w0k=0N-1akun-k.

When a<1a<1, then un is weighted more heavily than un-(N-1);un-(N-1); when a>1a>1, un-(N-1)un-(N-1) is weighted more heavily than un ; when a=1,una=1,un is weighted the same as un-(N-1).un-(N-1).

Exercise 3

Evaluate w 0 w 0 so that the exponential weighting sequence wn=wn=w0an(n=0,1,...,N-1)w0an(n=0,1,...,N-1) is a valid window (i.e., n=0N-1wn=1n=0N-1wn=1).

Exercise 4

Compute the moving average xn=k=0N-1w0akun-kxn=k=0N-1w0akun-k when the input sequence u n u n is

u n = b n , n 0 0 , n < 0 . u n = b n , n 0 0 , n < 0 .
(4)

What happens when b=ab=a? Can you explain this?

Collection Navigation

Content actions

Download:

Collection as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Module as:

PDF | More downloads ...

Add:

Collection to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks

Module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks