Bsoft 2.1.4
Bernard's software package
moving_average.h File Reference

Header file moving average calculations. More...

#include "Complex.h"
#include "matrix_linear.h"
#include "utilities.h"

Functions

vector< double > moving_average (long number, double *x, long window)
 Calculates a moving average over an array of data. More...
 
vector< double > moving_average (vector< double > &x, long window)
 Calculates a moving average over an array of data. More...
 
vector< Complex< float > > moving_average_complex (vector< Complex< float > > &x, long window)
 Calculates a moving average over an array of complex data. More...
 
vector< double > moving_polynomial (long order, long number, double *x, long window)
 Calculates a moving polynomial fit over an array of data. More...
 
vector< double > moving_polynomial (long order, vector< double > &x, long window)
 Calculates a moving polynomial fit over an array of data. More...
 
vector< double > moving_gradient (vector< double > &x, long window)
 Calculates a moving fit of the local gradient in an array of data. More...
 
vector< double > moving_curvature (vector< double > &x, long window)
 Calculates a moving fit of the local curvature in an array of data. More...
 

Detailed Description

Header file moving average calculations.

Author
Bernard Heymann
Date
Created: 20000430
Modified: 20221129

Function Documentation

◆ moving_average() [1/2]

vector< double > moving_average ( long  number,
double *  x,
long  window 
)

Calculates a moving average over an array of data.

Parameters
numbernumber of values in the array.
*xthe array.
windowsliding window length.
Returns
double* the moving average array.
All data points within a sliding window are averaged.
The window moves over the ends of the array and averages only the 
available points.
A new array is allocated and the moving averages returned.

◆ moving_average() [2/2]

vector< double > moving_average ( vector< double > &  x,
long  window 
)

Calculates a moving average over an array of data.

Parameters
&xthe array.
windowsliding window length.
Returns
vector<double> the moving average array.
All data points within a sliding window are averaged.
The window moves over the ends of the array and averages only the
available points.
A new array is allocated and the moving averages returned.

◆ moving_average_complex()

vector< Complex< float > > moving_average_complex ( vector< Complex< float > > &  x,
long  window 
)

Calculates a moving average over an array of complex data.

Parameters
&xthe array.
windowsliding window length.
Returns
Complex<float>* the moving average complex array.
All data points within a sliding window are averaged.
The window moves over the ends of the array and averages only the
available points.
A new array is allocated and the moving averages returned in it.

◆ moving_curvature()

vector< double > moving_curvature ( vector< double > &  x,
long  window 
)

Calculates a moving fit of the local curvature in an array of data.

Parameters
&xthe array.
windowsliding window length.
Returns
vector<double> the moving curvature fit array.
All data points within a sliding window are fit to a third-order polynomial.
The window moves over the ends of the array and fits only the
available points.

◆ moving_gradient()

vector< double > moving_gradient ( vector< double > &  x,
long  window 
)

Calculates a moving fit of the local gradient in an array of data.

Parameters
&xthe array.
windowsliding window length.
Returns
vector<double> the moving gradient fit array.
All data points within a sliding window are fit to a line.
The window moves over the ends of the array and fits only the
available points.

◆ moving_polynomial() [1/2]

vector< double > moving_polynomial ( long  order,
long  number,
double *  x,
long  window 
)

Calculates a moving polynomial fit over an array of data.

Parameters
orderpolynomial order.
numbernumber of values in the array.
*xthe array.
windowsliding window length.
Returns
vector<double> the moving polynomial fit array.
All data points within a sliding window are fit to a polynomial.
The window moves over the ends of the array and fits only the 
available points.
A new array is allocated and the moving polynomial fit values returned.

◆ moving_polynomial() [2/2]

vector< double > moving_polynomial ( long  order,
vector< double > &  x,
long  window 
)

Calculates a moving polynomial fit over an array of data.

Parameters
orderpolynomial order.
&xthe array.
windowsliding window length.
Returns
vector<double> the moving polynomial fit array.
All data points within a sliding window are fit to a polynomial.
The window moves over the ends of the array and fits only the
available points.
A new array is allocated and the moving polynomial fit values returned.