1.4.2.96 DSP_VectorVari16 Function
Computes the variance of N elements of a Vector.
Description
int16_t DSP_VectorVari16(int16_t *inVector, int N);
Calculates the variance on the first N elements of inVector and returns the 16-bit scalar result. The variance is a measure of the delta from mean values, and the mean value of the vector is computed in the process. The function has the form - var = 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 has 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.
Parameters
inVector pointer to source array of elements (int16_t)
N number of samples (int)
Returns
int16_t - Variance 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.
Example
int16_t vecStDevIn[32]={0x4000, 0xD99A, 0x1000, 0x6000,0x1999,0x1999,0x2666, 0x3333}; _// .2, -.3, .125, .75, .2, .2, .3, .4_ int16_t Var16Out; int Nvar = 4; Var16Out= DSP_VectorVari16(vecStDevIn, Nvar); _// 16-bit variance function_ _// Var16Out = 0x1AD8 (= 0.20974)_
C
int16_t DSP_VectorVari16 (int16_t * inVector , int N );