var

Functions
var
Complete List of ArrayFire Functions ArrayFire Functions by Category » Statistics » | Basic statistics functions

Find the variance of values in the input. More...

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

## Detailed Description

Find the variance of values in the input.

This function performs the operation across all batches present in the input simultaneously.

## 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.

## ◆ 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.

## ◆ 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_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/4]

AFAPI array af::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.

Examples:
  machine_learning/naive_bayes.cpp.

## ◆ var() [2/4]

AFAPI array af::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() [3/4]

AFAPI T af::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

## ◆ var() [4/4]

AFAPI T af::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