arrayfire.statistics module

Statistical algorithms (mean, var, stdev, etc).

arrayfire.statistics.corrcoef(x,y)[source]

Calculate the correlation coefficient of the input arrays.

Parameters
x: af.Array

The first input array.

y: af.Array

The second input array.

Returns
output: af.Array

Array containing the correlation coefficient of the input arrays.

arrayfire.statistics.cov(a,isbiased=False,dim=None)[source]

Calculate covariance along a given dimension.

Parameters
a: af.Array

The input array.

isbiased: optional: Boolean. default: False.

Boolean denoting whether biased estimate should be taken.

dim: optional: int. default: None.

The dimension for which to obtain the covariance from input data.

Returns
output: af.Array

Array containing the covariance of the input array along agiven dimension.

arrayfire.statistics.mean(a,weights=None,dim=None)[source]

Calculate mean along a given dimension.

Parameters
a: af.Array

The input array.

weights: optional: af.Array. default: None.

Array to calculate the weighted mean. Must match size of theinput array.

dim: optional: int. default: None.

The dimension for which to obtain the mean from input data.

Returns
output: af.Array

Array containing the mean of the input array along a givendimension.

arrayfire.statistics.meanvar(a,weights=None,bias=<VARIANCE.DEFAULT:0>,dim=-1)[source]

Calculate mean and variance along a given dimension.

Parameters
a: af.Array

The input array.

weights: optional: af.Array. default: None.

Array to calculate for the weighted mean. Must match size ofthe input array.

bias: optional: af.VARIANCE. default: DEFAULT.

population variance(VARIANCE.POPULATION) orsample variance(VARIANCE.SAMPLE).

dim: optional: int. default: -1.

The dimension for which to obtain the variance from input data.

Returns
mean: af.Array

Array containing the mean of the input array along a givendimension.

variance: af.Array

Array containing the variance of the input array along a givendimension.

arrayfire.statistics.median(a,dim=None)[source]

Calculate median along a given dimension.

Parameters
a: af.Array

The input array.

dim: optional: int. default: None.

The dimension for which to obtain the median from input data.

Returns
output: af.Array

Array containing the median of the input array along agiven dimension.

arrayfire.statistics.stdev(a,dim=None)[source]

Calculate standard deviation along a given dimension.

Parameters
a: af.Array

The input array.

dim: optional: int. default: None.

The dimension for which to obtain the standard deviation frominput data.

Returns
output: af.Array

Array containing the standard deviation of the input arrayalong a given dimension.

arrayfire.statistics.topk(data,k,dim=0,order=<TOPK.DEFAULT:0>)[source]

Return top k elements along a single dimension.

Parameters
data: af.Array

Input array to return k elements from.

k: scalar. default: 0

The number of elements to return from input array.

dim: optional: scalar. default: 0

The dimension along which the top k elements areextracted. Note: at the moment, topk() only supports theextraction of values along the first dimension.

order: optional: af.TOPK. default: af.TOPK.DEFAULT

The ordering of k extracted elements. Defaults to top k max values.

Returns
values: af.Array

Top k elements from input array.

indices: af.Array

Corresponding index array to top k elements.

arrayfire.statistics.var(a,isbiased=False,weights=None,dim=None)[source]

Calculate variance along a given dimension.

Parameters
a: af.Array

The input array.

isbiased: optional: Boolean. default: False.

Boolean denoting population variance (false) or samplevariance (true).

weights: optional: af.Array. default: None.

Array to calculate for the weighted mean. Must match size ofthe input array.

dim: optional: int. default: None.

The dimension for which to obtain the variance from input data.

Returns
output: af.Array

Array containing the variance of the input array along a givendimension.