A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

Functions
var
ArrayFire Functions | ArrayFire Functions by Category » Statistics » Basic statistics functions

## Functions
AFAPI array | var (const array &in, const bool isbiased=false, const dim_t dim=-1)
| C++ Interface for variance.
AFAPI array | var (const array &in, const af_var_bias bias, const dim_t dim=-1)
| C++ Interface for variance.
AFAPI array | var (const array &in, const array &weights, const dim_t dim=-1)
| C++ Interface for variance of weighted inputs.
template<typename T >
AFAPI T | var (const array &in, const bool isbiased=false)
| C++ Interface for variance of all elements.
template<typename T >
AFAPI T | var (const array &in, const af_var_bias bias)
| C++ Interface for variance of all elements.
template<typename T >
AFAPI T | var (const array &in, const array &weights)
| C++ Interface for variance of all elements in weighted input.
AFAPI af_err | af_var (af_array *out, const af_array in, const bool isbiased, const dim_t dim)
| C Interface for variance.
AFAPI af_err | af_var_v2 (af_array *out, const af_array in, const af_var_bias bias, const dim_t dim)
| C Interface for variance.
AFAPI af_err | af_var_weighted (af_array *out, const af_array in, const af_array weights, const dim_t dim)
| C Interface for variance of weighted input array.
AFAPI af_err | af_var_all (double *realVal, double *imagVal, const af_array in, const bool isbiased)
| C Interface for variance of all elements.
AFAPI af_err | af_var_all_v2 (double *realVal, double *imagVal, const af_array in, const af_var_bias bias)
| C Interface for variance of all elements.
AFAPI af_err | af_var_all_weighted (double *realVal, double *imagVal, const af_array in, const af_array weights)
| C Interface for variance of all elements in weighted input.

## Detailed Description

Find the variance of values in the input

This function performs the operation across all dimensions of the input array.

## Function Documentation

## ◆ af_var()

AFAPI af_err af_var | ( | af_array * | out,
|  | const af_array | in,
|  | const bool | isbiased,
|  | const dim_t | dim )

C Interface for variance.

Parameters

  [out] | out | will contain the variance of the input array along dimension `dim`
  [in] | in | is the input array
  [in] | isbiased | is boolean denoting Population variance (false) or Sample Variance (true)
  [in] | dim | the dimension along which the variance is extracted

Returns
  AF_SUCCESS if the operation is successful, otherwise an appropriate error code is returned.

Deprecated
  Use af_var_v2 instead

## ◆ af_var_all()

AFAPI af_err af_var_all | ( | double * | realVal,
|  | double * | imagVal,
|  | const af_array | in,
|  | const bool | isbiased )

C Interface for variance of all elements.

Parameters

  [out] | realVal | will contain the real part of variance of the entire input array
  [out] | imagVal | will contain the imaginary part of variance of the entire input array
  [in] | in | is the input array
  [in] | isbiased | is boolean denoting Population variance (false) or Sample Variance (true)

Returns
  AF_SUCCESS if the operation is successful, otherwise an appropriate error code is returned.

Deprecated
  Use af_var_all_v2 instead

## ◆ af_var_all_v2()

AFAPI af_err af_var_all_v2 | ( | double * | realVal,
|  | double * | imagVal,
|  | const af_array | in,
|  | const af_var_bias | bias )

C Interface for variance of all elements.

Parameters

  [out] | realVal | will contain the real part of variance of the entire input array
  [out] | imagVal | will contain the imaginary part of variance of the entire input array
  [in] | in | is the input array
  [in] | bias | The type of bias used for variance calculation. Takes of value of type af_var_bias

Returns
  AF_SUCCESS if the operation is successful, otherwise an appropriate error code is returned.

## ◆ af_var_all_weighted()

AFAPI af_err af_var_all_weighted | ( | double * | realVal,
|  | double * | imagVal,
|  | const af_array | in,
|  | const af_array | weights )

C Interface for variance of all elements in weighted input.

Parameters

  [out] | realVal | will contain the real part of variance of the entire weighted input array
  [out] | imagVal | will contain the imaginary part of variance of the entire weighted input array
  [in] | in | is the input array
  [in] | weights | is used to scale input `in` before getting variance

Returns
  AF_SUCCESS if the operation is successful, otherwise an appropriate error code is returned.

## ◆ af_var_v2()

AFAPI af_err af_var_v2 | ( | af_array * | out,
|  | const af_array | in,
|  | const af_var_bias | bias,
|  | const dim_t | dim )

C Interface for variance.

Parameters

  [out] | out | will contain the variance of the input array along dimension `dim`
  [in] | in | is the input array
  [in] | bias | The type of bias used for variance calculation. Takes of value of type af_var_bias
  [in] | dim | the dimension along which the variance is extracted

Returns
  AF_SUCCESS if the operation is successful, otherwise an appropriate error code is returned.

## ◆ af_var_weighted()

AFAPI af_err af_var_weighted | ( | af_array * | out,
|  | const af_array | in,
|  | const af_array | weights,
|  | const dim_t | dim )

C Interface for variance of weighted input array.

Parameters

  [out] | out | will contain the variance of the input array along dimension `dim`
  [in] | in | is the input array
  [in] | weights | is used to scale input `in` before getting variance
  [in] | dim | the dimension along which the variance is extracted

Returns
  AF_SUCCESS if the operation is successful, otherwise an appropriate error code is returned.

## ◆ var() [1/6]

template<typename T >

AFAPI T var | ( | const array & | in,
|  | const af_var_bias | bias )

C++ Interface for variance of all elements.

Parameters

  [in] | in | is the input array
  [in] | bias | The type of bias used for variance calculation. Takes of value of type af_var_bias.

Returns
  variance of the `in` array

## ◆ var() [2/6]

AFAPI array var | ( | const array & | in,
|  | const af_var_bias | bias,
|  | const dim_t | dim = -1 )

C++ Interface for variance.

Parameters

  [in] | in | is the input array
  [in] | bias | The type of bias used for variance calculation. Takes o value of type af_var_bias.
  [in] | dim | the dimension along which the variance is extracted

Returns
  the variance of the input array along dimension `dim`

Note
  `dim` is -1 by default. -1 denotes the first non-singleton dimension.

## ◆ var() [3/6]

template<typename T >

AFAPI T var | ( | const array & | in,
|  | const array & | weights )

C++ Interface for variance of all elements in weighted input.

Parameters

  [in] | in | is the input array
  [in] | weights | is used to scale input `in` before getting variance

Returns
  variance of the entire input array

## ◆ var() [4/6]

AFAPI array var | ( | const array & | in,
|  | const array & | weights,
|  | const dim_t | dim = -1 )

C++ Interface for variance of weighted inputs.

Parameters

  [in] | in | is the input array
  [in] | weights | is used to scale input `in` before getting variance
  [in] | dim | the dimension along which the variance is extracted

Returns
  the variance of the weighted input array along dimension `dim`

Note
  `dim` is -1 by default. -1 denotes the first non-singleton dimension.

## ◆ var() [5/6]

template<typename T >

AFAPI T var | ( | const array & | in,
|  | const bool | isbiased = false )

C++ Interface for variance of all elements.

Parameters

  [in] | in | is the input array
  [in] | isbiased | is boolean denoting Population variance (false) or Sample Variance (true)

Returns
  variance of the entire input array

Deprecated
  Use af::var that takes af_var_bias instead

## ◆ var() [6/6]

AFAPI array var | ( | const array & | in,
|  | const bool | isbiased = false,
|  | const dim_t | dim = -1 )

C++ Interface for variance.

Parameters

  [in] | in | is the input array
  [in] | isbiased | is boolean denoting Population variance (false) or Sample Variance (true)
  [in] | dim | the dimension along which the variance is extracted

Returns
  the variance of the input array along dimension `dim`

Note
  `dim` is -1 by default. -1 denotes the first non-singleton dimension.

Deprecated
  Use af::var that takes af_var_bias instead