Convolution Calculator
Interactive convolution calculator. Compute discrete convolution of two sequences, see step-by-step sums, and learn the intuition behind convolution in signals, probability, and deep learning.
Full original guide (expanded)
Convolution Calculator
Compute discrete convolution of two sequences, inspect each sum in \(y[k] = \sum_n x[n]\,h[k-n]\), and see how convolution behaves in signals, probability and deep learning.
Interactive discrete convolution of finite sequences
Enter two finite sequences (signals, kernels, filters, probability mass functions). The tool will:
- Parse sequences like 1, 2, 3 or 0.5 -1 0.5.
- Compute full, same, or valid convolution.
- Show each output sample as a sum of products.
- Provide quick statistics (length, energy) and notes on interpretation.
Separate values with commas or spaces. Up to ~50 samples for each sequence.
This is the filter, mask or impulse response. Convolution computes the output of a system with impulse response \(h\) fed by input \(x\).
Full keeps all samples, same matches main sequence length, valid avoids border effects.
A good mental model for convolution is “flip, slide, multiply, sum”:
- Flip the kernel \(h[n]\) to get \(h[-n]\).
- Slide it across the input \(x[n]\) (shifts \(k\)).
- At each shift, multiply overlapping elements.
- Sum those products to get \(y[k]\).
Try these toy examples in the calculator:
- Moving average: \(x = [1, 2, 3, 4]\), \(h = [\tfrac13, \tfrac13, \tfrac13]\).
- Edge detection: \(x = [0, 0, 1, 1, 1, 0]\), \(h = [1, 0, -1]\).
- Discrete PMFs: \(x = [0.25, 0.5, 0.25]\), \(h = [0.5, 0.5]\).
What is convolution?
Convolution is an operation that combines two functions or sequences into a new one. In the discrete-time case, given sequences \(x[n]\) and \(h[n]\), their convolution is a third sequence \(y[n]\) defined as
\(y[k] = (x * h)[k] = \sum_{n=-\infty}^{\infty} x[n]\,h[k-n]\).
Intuitively, convolution tells you how the shape of \(x\) is filtered, smeared or spread by \(h\). In signal processing, \(x\) is often an input signal and \(h\) is the impulse response of a system. In probability, convolution gives the distribution of the sum of independent random variables. In deep learning, convolution is the core operation behind convolutional neural networks (CNNs).
Discrete vs continuous convolution
Discrete-time convolution
For finite sequences, the sum in the definition is finite:
If \(x[n] = 0\) outside \(\{0,\dots,N-1\}\) and \(h[n] = 0\) outside \(\{0,\dots,M-1\}\), then \[(x*h)[k] = \sum_{n=0}^{N-1} x[n]\,h[k-n]\] and the non-zero part of \(y[k]\) has length \(N + M - 1\).
This is exactly what the calculator on this page computes.
Continuous-time convolution
For continuous-time signals \(f(t)\) and \(g(t)\), convolution is defined using an integral:
\((f * g)(t) = \int_{-\infty}^{\infty} f(\tau)\,g(t - \tau)\,d\tau.\)
The same flip-and-slide picture applies: \(g(t)\) is reversed to \(g(-t)\), shifted by \(t\), then overlapped and integrated with \(f(\tau)\).
Full, same, and valid convolution
When working with finite sequences (or arrays in code), you often choose one of three conventions:
- Full convolution: keep all samples where there is at least one overlapping pair. Length \(N + M - 1\).
- Same convolution: crop the full result to match the length of the “main” sequence (usually \(x\)).
- Valid convolution: keep only samples where the kernel lies fully inside the main sequence. Length \(\max(N,M) - \min(N,M) + 1\) when \(\max(N,M) \ge \min(N,M)\).
Many libraries (e.g. numerical or signal-processing toolkits) offer these three options; this calculator mirrors that behaviour.
Convolution in signal processing
In linear, time-invariant (LTI) systems, convolution is the fundamental input-output relation:
\(y[n] = (x*h)[n]\)
where \(h[n]\) is the system’s impulse response. Examples:
- Low-pass filtering: \(h[n]\) is a smoothing kernel, e.g. moving average.
- High-pass or edge detection: \(h[n]\) emphasizes differences, e.g. \([1, 0, -1]\).
- Echo / reverb: \(h[n]\) has several delayed peaks, modelling reflections.
Convolution and probability
If \(X\) and \(Y\) are independent discrete random variables with probability mass functions \(p_X\) and \(p_Y\), the distribution of the sum \(Z = X + Y\) is given by the convolution of the PMFs:
\(p_Z[k] = (p_X * p_Y)[k] = \sum_n p_X[n]\;p_Y[k-n].\)
In this context, convolution answers: “What is the probability that two independent random outcomes add up to a given value?”.
Convolution in deep learning and images
In image processing and CNNs, convolution is applied to 2D arrays (images) with small kernels:
- Blurring or denoising with smoothing kernels.
- Edge detection with Sobel or Laplacian kernels.
- Learned filters in CNN layers, trained to detect patterns such as edges, textures or shapes.
Mathematically, 2D convolution extends the same idea: flip the kernel in both dimensions, slide it over the image, multiply overlapping pixels and add them.
Convolution – FAQ
What is the difference between convolution and correlation?
In (cross-)correlation, one sequence is shifted but not reversed in the same way as in convolution. Correlation measures similarity as one signal slides across another; convolution describes the response of a system with impulse response \(h\) to an input \(x\). For real, symmetric kernels, convolution and correlation coincide.
Does the order of convolution matter?
Convolution is commutative: \(x * h = h * x\). However, when you interpret \(x\) as “input” and \(h\) as “system”, the roles carry meaning even if the numeric result is the same.
How does convolution interact with the Fourier transform?
One of the most important properties is the convolution theorem: convolution in time corresponds to multiplication in frequency, and vice versa. For example, for suitable signals, \(\mathcal{F}\{x*h\} = \mathcal{F}\{x\}\cdot\mathcal{F}\{h\}\).
When should I use “valid” instead of “same” convolution?
Use valid when you want to avoid boundary effects and only keep samples where the kernel is fully inside the data (e.g. in some numerical algorithms). Use same if you want an output aligned and sized like the original signal (e.g. feature maps in CNNs).
Can convolution be inverted?
In principle, if the system’s frequency response never vanishes, you can undo convolution via deconvolution or inverse filtering in the frequency domain. In practice, noise and zeros in the spectrum make deconvolution numerically delicate.
Frequently Asked Questions
How accurate is this convolution calculator?
It uses standard JavaScript floating-point arithmetic with configurable rounding. For educational and most engineering purposes on normalized data, this is more than adequate. If you need higher precision, round only at the end and keep track of units and scaling factors in your workflow.
Can I use this with probability mass functions?
Yes. Enter non-negative numbers that sum to 1 in each sequence, choose the “Probability (PMFs)” interpretation, and the result describes the distribution of the sum of two independent discrete random variables. Minor rounding differences may cause the sum to deviate slightly from 1; you can renormalize if needed.
Does this calculator support 2D image convolution?
No, this page focuses on 1D discrete convolution for sequences. However, the formulas and intuition you learn here carry over directly to 2D convolution used in image processing and convolutional neural networks.
Formula (LaTeX) + variables + units
(x*h)[k] = \sum_{n=0}^{N-1} x[n]\,h[k-n]
','\
\(y[k] = (x * h)[k] = \sum_{n=-\infty}^{\infty} x[n]\,h[k-n]\).
If \(x[n] = 0\) outside \(\{0,\dots,N-1\}\) and \(h[n] = 0\) outside \(\{0,\dots,M-1\}\), then \[(x*h)[k] = \sum_{n=0}^{N-1} x[n]\,h[k-n]\] and the non-zero part of \(y[k]\) has length \(N + M - 1\).
\((f * g)(t) = \int_{-\infty}^{\infty} f(\tau)\,g(t - \tau)\,d\tau.\)
\(p_Z[k] = (p_X * p_Y)[k] = \sum_n p_X[n]\;p_Y[k-n].\)
- No variables provided in audit spec.
- NIST — Weights and measures — nist.gov · Accessed 2026-01-19
https://www.nist.gov/pml/weights-and-measures - FTC — Consumer advice — consumer.ftc.gov · Accessed 2026-01-19
https://consumer.ftc.gov/
Last code update: 2026-01-19
- Initial audit spec draft generated from HTML extraction (review required).
- Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
- Confirm sources are authoritative and relevant to the calculator methodology.