FunctionMean with weights
Syntax C/C++#include <VFstd.h>
float VF_meanwW( fVector X, fVector Wt, ui size );

    (similarly VD_,   VE_)
fComplex VCF_meanwW( cfVector X, fVector Wt, ui size );
    (similarly VCD_,   VCE_)
C++ VecObj#include <OptiVec.h>
T vector<T>::meanwW( const vector<T>& Wt );
fComplex vector<complex<T>>::meanwW( const vector<T>& Wt );
Pascal/Delphiuses VFstd;
function VF_meanwW( X, Wt:fVector; size:UIntSize ): Single;

    (similarly VD_,   VE_)

function VCF_meanwW( X:cfVector; Wt:fVector; size:UIntSize ):fComplex;

Alternative syntax (obsolete, but still supported): procedure VCF_meanwW( var Mean:fComplex; X:cfVector; Wt:fVector; size:UIntSize );
    (similarly VCD_,   VCE_)
CUDA function C/C++#include <cudaVFstd.h>
int cudaVF_meanwW( float *h_RetVal, fVector d_X, fVector d_Wt, ui size );
int cusdVF_meanwW( float *d_RetVal, fVector d_X, fVector d_Wt, ui size );
float VFcu_meanwW( fVector h_X, fVector h_Wt, ui size );
CUDA function Pascal/Delphiuses VFstd;
function cudaVF_meanwW( var h_RetVal:Single; d_X, d_Wt:fVector; size:UIntSize ): IntBool;
function cusdVF_meanwW( d_RetVal:PSingle; d_X, d_Wt:fVector; size:UIntSize ): IntBool;
function VFcu_meanwW( h_X, h_Wt:fVector; size:UIntSize ): Single;
DescriptionmeanwW = (1 / sum( Wti )) * sum( Xi * Wti )
Notice that, also in the complex version, the weights are always real rather than complex.
Error handlingnone
Return valueweighted mean of the vector elements (except complex versions in Pascal/Delphi).
See alsoVF_mean,   VF_sum,   VF_ssq,   VF_ssqdevC,   VF_median,   VF_meanvarwW,   VF_linregresswW

VectorLib Table of Contents  OptiVec home