Moving average
A moving average is a sequence of averages computed over a shifting window of consecutive or neighboring values, commonly used to smooth variation in ordered data.
Investing for Programmers
A moving average is a statistic that averages observations within a rolling time window to smooth short-term fluctuations.
- How it is used
- Uses rolling averages to smooth price charts, identify trends, and form technical trading signals.
- How deep it goes
- Explains rolling-window calculation, weighting choices, plotting, crossovers, and backtesting, but stops short of proving predictive effectiveness.
- Examples
- Demonstrates pandas calculations, NVIDIA historical prices, moving-average ribbons, SMA crossovers, and comparative historical backtests.
- What you can do after
- Build it from scratch with pandas, visualize multiple windows, and evaluate crossover rules through historical backtests including transaction costs.
Read how Investing for Programmers explains moving average →
Statistics Every Programmer Needs
A moving average represents a time-series value or forecast using averages of observations in a moving time window.
- How it is used
- Uses moving averages to smooth time-series noise and expose trends or seasonal patterns for forecasting and decision-making.
- How deep it goes
- Defines the smoothing role and forecasting context but stops short of specifying a window formula, implementation, or parameter-selection procedure.
- Examples
- Uses stock closing prices, economic indicators, patient vital signs, web traffic, and train-test forecasting of Apple prices as examples.
- What you can do after
- Evaluate whether smoothing is suitable by examining time-series structure and comparing forecasts with held-out observations.
Read how Statistics Every Programmer Needs explains moving average →
Inside Deep Learning: Math, Algorithms, Models
An image-smoothing transformation that averages local neighborhoods to reduce high-frequency detail before downsampling.
- How it is used
- Smooths image neighborhoods and blurs pooling outputs before downsampling to mitigate aliasing.
- How deep it goes
- Defines neighborhood averaging, demonstrates a 3×3 convolution, and connects binomial blur to anti-aliased pooling.
- Examples
- Uses a 3×3 kernel on an MNIST digit and stride-one max-pooling outputs to illustrate blurring.
- What you can do after
- Apply via convolution to average neighboring pixels, or blur stride-one max-pooling outputs before downsampling.
Read how Inside Deep Learning: Math, Algorithms, Models explains moving average →
Natural Language Processing in Action, Second Edition
A moving average is an aggregate that summarizes recent values over a changing or weighted window of observations.
- How it is used
- Uses local averaging to extract short patterns from numeric sequences before learned CNN filters.
- How deep it goes
- Explains weighted sliding computation in pure Python and stops short of training or fitting the kernel.
- Examples
- Uses cryptocurrency prices, rainfall reports, Morse code, and a part-of-speech sequence from a quotation.
- What you can do after
- Apply it via pure Python to build a hardcoded detector for short sequence patterns.
Read how Natural Language Processing in Action, Second Edition explains moving average →
Data-Driven Cybersecurity
A simple moving average is the arithmetic mean of observations within a fixed-length sliding window.
- How it is used
- Supports cybersecurity monitoring and feedback loops by revealing durable trends behind noisy incident metrics.
- How deep it goes
- Defines sliding-window averaging, demonstrates a five-day implementation and plot, but does not develop the underlying statistical theory.
- Examples
- Uses 30 simulated days of malware detections, five-day SMA and EMA calculations, plotted trends, and deviations flagged for investigation.
- What you can do after
- Evaluate cybersecurity trends, compare sustained movement with daily noise, and prioritize investigation of unusual deviations.
Read how Data-Driven Cybersecurity explains moving average →
Demand Forecasting Best Practices
A moving average is a forecasting method that predicts a value by averaging observations from a recent fixed number of periods.
- How it is used
- Uses recent demand averages as a practical benchmark for judging forecasting accuracy and improvement.
- How deep it goes
- Explains window selection, lag alignment, overfitting safeguards, and ongoing comparison, but does not develop implementation details.
- Examples
- Uses three-to-six-period windows, past-sales comparisons, promotion-driven demand, and a six-month multi-team forecasting scenario.
- What you can do after
- Apply it to compare a forecast with past-sales demand and identify whether further planning improvement is warranted.
Read how Demand Forecasting Best Practices explains moving average →
Math and Architectures of Deep Learning
A smoothing technique that reduces short-scale fluctuations by averaging nearby values in one dimension.
- How it is used
- Uses convolution to smooth signals and images, making broad patterns more visible by reducing local fluctuations and noise.
- How deep it goes
- Defines normalized uniform kernels, explains their averaging and low-pass behavior, and demonstrates fixed-weight PyTorch implementations in one and two dimensions.
- Examples
- Uses a three-value moving average, a fluctuating curve, and a salt-and-pepper-noisy text image as concrete demonstrations.
- What you can do after
- Apply it via PyTorch by configuring Conv1d or Conv2d with fixed uniform weights and correctly shaped tensors.
Read how Math and Architectures of Deep Learning explains moving average →
Also covered in
- Deep Learning with PyTorch, Second Edition
- Kafka Streams in Action, Second Edition
- Deep Learning with JAX
- Functional Programming in Scala, Second Edition
- DuckDB in Action
- Grokking Simplicity
What to know first
- PythonPython is a high-level, general-purpose, dynamically typed programming language with readable syntax and support for multiple programming paradigms.
- stock priceA stock price is the market value of one share of a publicly traded company or security at a particular time.
- sequenceA sequence is an ordered collection of elements whose positions determine the order in which they are arranged or traversed.
- convolutional neural networkA convolutional neural network is a neural-network architecture that processes structured inputs with convolutional operations, typically using learned local filters to capture patterns.
Related concepts
- exponential moving averageincludes · A recursively updated average that combines new values with a prior average using exponentially declining weights, giving newer values greater influence.
- arimapart of · ARIMA is a statistical time-series model that combines autoregressive terms, differencing, and moving-average terms to represent temporal dependence and generate forecasts.
- MACDmeasured by · MACD is a momentum indicator based on the difference between short-term and long-term exponential moving averages and a smoothed signal line.
- moving average ribbonused by · A moving average ribbon is a visualization containing multiple moving-average lines calculated over different time windows.
- SMA crossover strategyused by · An SMA crossover strategy generates trading decisions from the relative crossings of simple moving averages with different time windows.
Questions about moving average
What is moving average?
A moving average is a sequence of averages computed over a shifting window of consecutive or neighboring values, commonly used to smooth variation in ordered data.
Which Manning books explain moving average?
Investing for Programmers, Statistics Every Programmer Needs, Inside Deep Learning: Math, Algorithms, Models, Natural Language Processing in Action, Second Edition, Data-Driven Cybersecurity, Demand Forecasting Best Practices and Math and Architectures of Deep Learning.
What should I know before learning moving average?
Manning books that teach moving average usually introduce Python, stock price, sequence and convolutional neural network first.
What kinds of moving average are there?
Kinds of moving average include exponential moving average.
What is moving average part of?
Moving average is part of arima. ARIMA is a statistical time-series model that combines autoregressive terms, differencing, and moving-average terms to represent temporal dependence and generate forecasts.
What is moving average also called?
Moving average is also called SMA.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.






