In statistical analysis, and for example in the analysis of stock exchange data, one may be interested into the following two situations:
1. One has a long sequence of items and wants to calculate a certain number of averages, by averaging on different numbers of items, i.e., using different lengths for the moving average window.
2. One has a series of sequences, stored consecutively in memory, and wants to average them in parallel with a fixed averaging window of size 2 * RADIUS + 1.
Below, a...

More
# Moving Average

# 1D Moving Average in CUDA

The moving average operator is a fundamental operator in statistics. The Wikipedia article provides an extensive insight on this topic.
Its CUDA implementation provides a very good example on how using shared memory and on how loading and managing halo regions in shared memory.
Below is a full worked example implementing the moving average operator in CUDA.
#include <thrust/device_vector.h>
#define RADIUS 3
#define BLOCKSIZE 32
/*******************/
/* iDivUp FUNCTION */
/******...

More
# Implementing an exponential moving average filter by CUDA Thrust

Suppose that one has the exponential moving average filter defined by the difference equation below
y[n] = y[n-1] * beta + alpha * x[n]
where alpha and beta are constants.
The question is on how to efficiently implementing this in CUDA.
One possibility would be to calculate the explicit form of the filter response and then using the primitives offered by CUDA Thrust.
In particular, by simple algebra, one can find the following:
y[1] = beta * y[0] + alpha * x[1]
y[2] = beta^2 * y[0] + alpha * be...

More