A high-performance general-purpose compute library
statistics.h
Go to the documentation of this file.
1/*******************************************************
2 * Copyright (c) 2014, ArrayFire
3 * All rights reserved.
4 *
5 * This file is distributed under 3-clause BSD license.
6 * The complete license agreement can be obtained at:
7 * http://arrayfire.com/licenses/BSD-3-Clause
8 ********************************************************/
9
10#pragma once
11#include <af/defines.h>
12
13#ifdef __cplusplus
14namespace af
15{
16class array;
17
29AFAPI array mean(const array& in, const dim_t dim=-1);
30
43AFAPI array mean(const array& in, const array& weights, const dim_t dim=-1);
44
60AF_DEPRECATED("Use \ref af::var(const array&, const af_var_bias, const dim_t)")
61AFAPI array var(const array& in, const bool isbiased=false, const dim_t dim=-1);
62
63#if AF_API_VERSION >= 38
77AFAPI array var(const array &in, const af_var_bias bias, const dim_t dim = -1);
78#endif
79
92AFAPI array var(const array& in, const array &weights, const dim_t dim=-1);
93
94#if AF_API_VERSION >= 37
107AFAPI void meanvar(array& mean, array& var, const array& in, const array& weights,
108 const af_var_bias bias = AF_VARIANCE_POPULATION, const dim_t dim=-1);
109#endif
110
124AF_DEPRECATED("Use af::stdev(const array&, const af_var_bias, const dim_t)")
125AFAPI array stdev(const array& in, const dim_t dim=-1);
126
127#if AF_API_VERSION >= 38
141AFAPI array stdev(const array &in, const af_var_bias bias,
142 const dim_t dim = -1);
143#endif
144
158AF_DEPRECATED("Use af::cov(const af::array&, const array&, conv af_var_bias)")
159AFAPI array cov(const array& X, const array& Y, const bool isbiased=false);
160
161#if AF_API_VERSION >= 38
173AFAPI array cov(const array &X, const array &Y, const af_var_bias bias);
174#endif
175
187AFAPI array median(const array& in, const dim_t dim=-1);
188
197template<typename T>
198AFAPI T mean(const array& in);
199
209template<typename T>
210AFAPI T mean(const array& in, const array& weights);
211
224template <typename T>
225AF_DEPRECATED("Use af::var(const af::array&, const af_var_bias)")
226AFAPI T var(const array &in, const bool isbiased = false);
227
228#if AF_API_VERSION >= 38
239template <typename T> AFAPI T var(const array &in, const af_var_bias bias);
240#endif
241
251template<typename T>
252AFAPI T var(const array& in, const array& weights);
253
264template <typename T>
265AF_DEPRECATED("Use af::stdev(const array&, const af_var_bias)")
266AFAPI T stdev(const array &in);
267
268#if AF_API_VERSION >= 38
279template <typename T> AFAPI T stdev(const array &in, const af_var_bias bias);
280#endif
281
290template<typename T>
291AFAPI T median(const array& in);
292
304template<typename T>
305AFAPI T corrcoef(const array& X, const array& Y);
306
307#if AF_API_VERSION >= 36
327AFAPI void topk(array &values, array &indices, const array& in, const int k,
328 const int dim = -1, const topkFunction order = AF_TOPK_MAX);
329#endif
330}
331#endif
332
333#ifdef __cplusplus
334extern "C" {
335#endif
336
348AFAPI af_err af_mean(af_array *out, const af_array in, const dim_t dim);
349
362AFAPI af_err af_mean_weighted(af_array *out, const af_array in, const af_array weights, const dim_t dim);
363
378AF_DEPRECATED("Use af_var_v2")
379AFAPI af_err af_var(af_array *out, const af_array in, const bool isbiased, const dim_t dim);
380
381#if AF_API_VERSION >= 38
398 const dim_t dim);
399#endif
400
414AFAPI af_err af_var_weighted(af_array *out, const af_array in, const af_array weights, const dim_t dim);
415
416#if AF_API_VERSION >= 37
430 const af_array weights, const af_var_bias bias, const dim_t dim);
431#endif
432
446AF_DEPRECATED("Use af_stdev_v2")
447AFAPI af_err af_stdev(af_array *out, const af_array in, const dim_t dim);
448
449#if AF_API_VERSION >= 38
466 const af_var_bias bias, const dim_t dim);
467#endif
468
483AF_DEPRECATED("Use af_cov_v2")
484AFAPI af_err af_cov(af_array* out, const af_array X, const af_array Y, const bool isbiased);
485
486#if AF_API_VERSION >= 38
501 const af_var_bias bias);
502#endif
503
515AFAPI af_err af_median(af_array* out, const af_array in, const dim_t dim);
516
528AFAPI af_err af_mean_all(double *real, double *imag, const af_array in);
529
542AFAPI af_err af_mean_all_weighted(double *real, double *imag, const af_array in, const af_array weights);
543
544
559AF_DEPRECATED("Use af_var_all_v2")
560AFAPI af_err af_var_all(double *realVal, double *imagVal, const af_array in, const bool isbiased);
561
562#if AF_API_VERSION >= 38
578AFAPI af_err af_var_all_v2(double *realVal, double *imagVal, const af_array in,
579 const af_var_bias bias);
580#endif
581
594AFAPI af_err af_var_all_weighted(double *realVal, double *imagVal, const af_array in, const af_array weights);
595
609AF_DEPRECATED("Use af_stdev_all_v2")
610AFAPI af_err af_stdev_all(double *real, double *imag, const af_array in);
611
612#if AF_API_VERSION >= 38
628AFAPI af_err af_stdev_all_v2(double *real, double *imag, const af_array in,
629 const af_var_bias bias);
630#endif
631
643AFAPI af_err af_median_all(double *realVal, double *imagVal, const af_array in);
644
659AFAPI af_err af_corrcoef(double *realVal, double *imagVal, const af_array X, const af_array Y);
660
661#if AF_API_VERSION >= 36
681AFAPI af_err af_topk(af_array *values, af_array *indices, const af_array in,
682 const int k, const int dim, const af_topk_function order);
683#endif
684
685#ifdef __cplusplus
686}
687#endif
A multi dimensional data container.
Definition: array.h:37
long long dim_t
Definition: defines.h:56
af_err
Definition: defines.h:71
void * af_array
Definition: defines.h:240
#define AF_DEPRECATED(msg)
Definition: defines.h:44
af_topk_function
Definition: defines.h:511
@ AF_TOPK_MAX
Top k max values.
Definition: defines.h:513
af_var_bias
Definition: defines.h:522
@ AF_VARIANCE_POPULATION
Population variance.
Definition: defines.h:525
#define AFAPI
Definition: defines.h:38
AFAPI af_err af_corrcoef(double *realVal, double *imagVal, const af_array X, const af_array Y)
C Interface for correlation coefficient.
AFAPI T corrcoef(const array &X, const array &Y)
C++ Interface for correlation coefficient.
AFAPI af_err af_cov(af_array *out, const af_array X, const af_array Y, const bool isbiased)
C Interface for covariance.
AFAPI af_err af_cov_v2(af_array *out, const af_array X, const af_array Y, const af_var_bias bias)
C Interface for covariance.
AFAPI array cov(const array &X, const array &Y, const bool isbiased=false)
C++ Interface for covariance.
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.
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.
AFAPI array mean(const array &in, const dim_t dim=-1)
C++ Interface for mean.
AFAPI af_err af_mean(af_array *out, const af_array in, const dim_t dim)
C Interface for mean.
AFAPI af_err af_mean_all(double *real, double *imag, const af_array in)
C Interface for mean of all elements.
AFAPI array median(const array &in, const dim_t dim=-1)
C++ Interface for median.
AFAPI af_err af_median(af_array *out, const af_array in, const dim_t dim)
C Interface for median.
AFAPI af_err af_median_all(double *realVal, double *imagVal, const af_array in)
C Interface for median.
AFAPI af_err af_stdev_all(double *real, double *imag, const af_array in)
C Interface for standard deviation of all elements.
AFAPI array stdev(const array &in, const dim_t dim=-1)
C++ Interface for standard deviation.
AFAPI af_err af_stdev_all_v2(double *real, double *imag, const af_array in, const af_var_bias bias)
C Interface for standard deviation of all elements.
AFAPI af_err af_stdev(af_array *out, const af_array in, const dim_t dim)
C Interface for standard deviation.
AFAPI af_err af_stdev_v2(af_array *out, const af_array in, const af_var_bias bias, const dim_t dim)
C Interface for standard deviation.
AFAPI void topk(array &values, array &indices, const array &in, const int k, const int dim=-1, const topkFunction order=AF_TOPK_MAX)
C++ Interface for finding top k elements along a given dimension.
AFAPI af_err af_topk(af_array *values, af_array *indices, const af_array in, const int k, const int dim, const af_topk_function order)
C Interface for finding top k elements along a given dimension.
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 array var(const array &in, const bool isbiased=false, const dim_t dim=-1)
C++ Interface for variance.
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.
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(af_array *out, const af_array in, const bool isbiased, const dim_t dim)
C Interface for variance.
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_v2(af_array *out, const af_array in, const af_var_bias bias, const dim_t dim)
C Interface for variance.
Definition: algorithm.h:15
AFAPI void meanvar(array &mean, array &var, const array &in, const array &weights, const af_var_bias bias=AF_VARIANCE_POPULATION, const dim_t dim=-1)
C++ Interface for mean and variance.
AFAPI af_err af_meanvar(af_array *mean, af_array *var, const af_array in, const af_array weights, const af_var_bias bias, const dim_t dim)
C Interface for mean and variance.