mean

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

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

## Functions
AFAPI array | mean (const array &in, const dim_t dim=-1)
| C++ Interface for mean. More...
AFAPI array | mean (const array &in, const array &weights, const dim_t dim=-1)
| C++ Interface for mean of weighted inputs. More...
template<typename T >
AFAPI T | mean (const array &in)
| C++ Interface for mean of all elements. More...
template<typename T >
AFAPI T | mean (const array &in, const array &weights)
| C++ Interface for mean of all elements in weighted input. More...
AFAPI af_err | af_mean (af_array *out, const af_array in, const dim_t dim)
| C Interface for mean. More...
AFAPI af_err | af_mean_weighted (af_array *out, const af_array in, const af_array weights, const dim_t dim)
| C Interface for mean of weighted input array. More...
AFAPI af_err | af_mean_all (double *real, double *imag, const af_array in)
| C Interface for mean of all elements. More...
AFAPI af_err | af_mean_all_weighted (double *real, double *imag, const af_array in, const af_array weights)
| C Interface for mean of all elements in weighted input. More...

## Detailed Description

Find the mean of values in the input.

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

## Function Documentation

## ◆ af_mean()

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

C Interface for mean.

Parameters

  [out] | out | will contain the mean of the input array along dimension `dim`
  [in] | in | is the input array
  [in] | dim | the dimension along which the mean is extracted

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

## ◆ af_mean_all()

AFAPI af_err af_mean_all | ( | double * | real,
|  | double * | imag,
|  | const af_array | in
| ) |  |

C Interface for mean of all elements.

Parameters

  [out] | real | will contain the real part of mean of the entire input array
  [out] | imag | will contain the imaginary part of mean of the entire input array
  [in] | in | is the input array

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

## ◆ af_mean_all_weighted()

AFAPI af_err af_mean_all_weighted | ( | double * | real,
|  | double * | imag,
|  | const af_array | in,
|  | const af_array | weights
| ) |  |

C Interface for mean of all elements in weighted input.

Parameters

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

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

## ◆ af_mean_weighted()

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

C Interface for mean of weighted input array.

Parameters

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

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

## ◆ mean() [1/4]

AFAPI array af::mean | ( | const array & | in,
|  | const dim_t | dim = `-1`
| ) |  |

C++ Interface for mean.

Parameters

  [in] | in | is the input array
  [in] | dim | the dimension along which the mean is extracted

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

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

Examples:
  financial/heston_model.cpp, image_processing/adaptive_thresholding.cpp, and machine_learning/naive_bayes.cpp.

## ◆ mean() [2/4]

AFAPI array af::mean | ( | const array & | in,
|  | const array & | weights,
|  | const dim_t | dim = `-1`
| ) |  |

C++ Interface for mean of weighted inputs.

Parameters

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

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

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

## ◆ mean() [3/4]

AFAPI T af::mean | ( | const array & | in | ) |

C++ Interface for mean of all elements.

Parameters

  [in] | in | is the input array

Returns
  mean of the entire input array

## ◆ mean() [4/4]

AFAPI T af::mean | ( | const array & | in,
|  | const array & | weights
| ) |  |

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

Parameters

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

Returns
  mean of the entire weighted input array