VF_meanvar | VD_meanvar | VE_meanvar |
|
Function | Mean and variance of a one-dimensional distribution |
|
Syntax C/C++ | #include <VFstd.h>
float VF_meanvar( float *Var, fVector X, ui size ); |
C++ VecObj | #include <OptiVec.h>
T vector<T>::meanvar( T *Var ); |
Pascal/Delphi | uses VFstd;
function VF_meanvar( var Variance:Single; X:fVector; size:UIntSize ): Single; |
|
CUDA function C/C++ | #include <cudaVFstd.h>
int cudaVF_meanvar( float *h_RetValMean, float *h_RetValVariance, fVector d_X, ui size );
int cusdVF_meanvar( float *d_RetValMean, float *d_RetValVariance, fVector d_X, ui size );
float VFcu_meanvar( float *h_RetValVariance, fVector h_X, ui size );
|
CUDA function Pascal/Delphi | uses VFstd;
function cudaVF_meanvar( var h_RetValMean, h_RetValVariance:Single; d_X:fVector; size:UIntSize ): IntBool;
function cusdVF_meanvar( d_RetValMean, d_RetValVariance:PSingle; d_X:fVector; size:UIntSize ): IntBool;
function VFcu_meanvar( h_X:fVector; size:UIntSize ): Single;
|
|
Description | mean = (1 / size) * sum( Xi )
var = (1 / (size−1)) * sum( (Xi - mean)2 )
Note that the denominator in the definition of var is size−1, whereas, in the routine VF_varianceC, it is simply size.The reason for that difference is that here the mean is calculated first and then the variance is determined using this value, whereas in VF_varianceC, the parameter C is pre-set. The mean is returned and the variance stored at the address passed as "Var" (C/C++), or in the variable "variance" (Pascal/Delphi). |
|
Error handling | In the case of size=1, the variance (which should be infinitely large) is set to HUGE_VAL. |
|
Return value | mean of the vector elements. |
|
|