The C++ interface for variance. More...

array var (const array &input, bool isbiased=false, int dim=-1)
 Variance along a dimension. More...
 
array var (const array &input, const array weights, int dim=-1)
 Weighted variance along a dimension. More...
 
template<typename ty >
ty var (const array &input, bool isbiased=false)
 Variance of all elements in array. More...
 
template<typename ty >
ty var (const array &input, const array weights)
 Weighted variance of all elements in array. More...
 

Detailed Description

The C++ interface for variance.

Returns the variance of a set of elements

Function Documentation

array af::var ( const array &  input,
bool  isbiased = false,
int  dim = -1 
)

Variance along a dimension.

Parameters
[in]input
[in]isbiasedif true then use sample variance (N); otherwise if false (default) use population variance (N - 1) where N=input.elements()
[in]dimdimension along which to operate (-1 indicates first non-singleton dimension)
array af::var ( const array &  input,
const array  weights,
int  dim = -1 
)

Weighted variance along a dimension.

Parameters
[in]input
[in]weightsplaced on each element (same size as input)
[in]dimdimension along which to operate (-1 indicates first non-singleton dimension)
Returns
variance using nonnegative weights instead of unit weight
ty af::var ( const array &  input,
bool  isbiased = false 
)

Variance of all elements in array.

array a = array(seq(5));
print(a); // 0 1 2 3 4
float m = var<float>(a);
printf("%f\n",m); // 2.5
Parameters
[in]input
[in]isbiasedif true then use sample variance (N); otherwise if false (default) use population variance (N - 1) where N=input.elements()
ty af::var ( const array &  input,
const array  weights 
)

Weighted variance of all elements in array.

Parameters
[in]input
[in]weightsplaced on each element (same size as input)