1.4.2.91 DSP_VectorStdDev16 Function

Computes the Standard Deviation of a Vector.

Description

int16_t DSP_VectorStdDev16(int16_t *inVector, int N);

Calculates the standard deviation on the first N elements of inVector and returns the 16-bit scalar result. The standard deviation is the square root of the variance, which is a measure of the delta from mean values. The mean value of the vector is computed in the process. The function has the form - StdDev = SQRT(sum((x(i) - M(N))^2) / (N-1)) where N is the number of vector elements x(i) is a single element in the vector M(N) is the mean of the N elements of the vector.

Input values of the vector and output scalar value is Q15 fractional format. This format has data that ranges from -1 to 1, and ha internal saturation limits of those same values. Some care has been taken to reduce the impact of saturation by adding processing steps to effectively complete the processing in blocks. However, in some extreme cases of data variance it is still possible to reach the saturation limits.

Preconditions

The pointers inVector must be aligned on 4-byte boundaries. N must be greater than or equal to four and a multiple of four.

Dependent on use of the LibQ library.

Parameters

inVector pointer to source array of elements (int16_t)

N number of samples (int)

Returns

int16_t - Standard Deviation of N selected elements

Remarks

The input vector elements number, N, must be at least 4 and a multiple of 4. This function is optimized with microMIPS and M14KCe ASE DSP instructions. This function is dependent on the LibQ library, and the _LIBQ_Q16Sqrt specifically.

Example

int16_t vecStDevIn[32]={0x4000, 0xD99A, 0x1000, 0x6000,0x1999,0x1999,0x2666, 0x3333};

_// .2, -.3, .125, .75, .2, .2, .3, .4_

int16_t StDevOut, Var16Out;

int Nstdev = 4;

StDevOut = DSP_VectorStdDev16(vecStDevIn, Nstdev);

_// StDevOut = 0x3A9E (= 0.45797)_

C

int16_t DSP_VectorStdDev16 (int16_t * inVector , int  N );