SHOGUN  6.1.3
Statistics.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2011-2016 Heiko Strathmann
8  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9  *
10  * Most cdf routines are wrappers for CDFLIB, part of the public domain NETLIB.
11  * https://people.sc.fsu.edu/~jburkardt/f_src/cdflib/cdflib.html
12  */
13
14 #ifndef __STATISTICS_H_
15 #define __STATISTICS_H_
16
17 #include <shogun/lib/config.h>
18 #include <shogun/base/SGObject.h>
19 #include <shogun/lib/SGVector.h>
20 #include <shogun/io/SGIO.h>
21
22 namespace shogun
23 {
24 template<class T> class SGMatrix;
25 template<class T> class SGSparseMatrix;
26
30 class CStatistics: public CSGObject
31 {
32
33 public:
34
41  template<class T>
43  {
44  floatmax_t sum = 0;
45
46  for ( index_t i = 0 ; i < vec.vlen ; ++i )
47  sum += vec[i];
48
49  return sum/vec.vlen;
50  }
51
60  static float64_t variance(SGVector<float64_t> values);
61
71
83  bool col_wise=true);
84
98  bool col_wise=true);
99
113  SGMatrix<float64_t> values, bool col_wise=true);
114
128  SGMatrix<float64_t> observations, bool in_place=false);
129
131  static inline float64_t lgamma(float64_t x)
132  {
133  return ::lgamma((double) x);
134  }
135
138  static inline floatmax_t lgammal(floatmax_t x)
139  {
140 #ifdef HAVE_LGAMMAL
141  return ::lgammal((long double) x);
142 #else
143  return ::lgamma((double) x);
144 #endif // HAVE_LGAMMAL
145  }
146
148  static inline float64_t tgamma(float64_t x)
149  {
150  return ::tgamma((double) x);
151  }
152
166
182
194  static float64_t normal_cdf(float64_t x, float64_t std_dev=1);
195
211  float64_t std_dev=1);
212
224  static float64_t lnormal_cdf(float64_t x);
225
233  static float64_t chi2_cdf(float64_t x, float64_t k);
234
244
251
254  static float64_t mutual_info(float64_t* p1, float64_t* p2, int32_t len);
255
259  float64_t* p, float64_t* q, int32_t len);
260
262  static float64_t entropy(float64_t* p, int32_t len);
263
268
273
278  static SGVector<int32_t> sample_indices(int32_t sample_size, int32_t N);
279
281  virtual const char* get_name() const
282  {
283  return "Statistics";
284  }
285
291  static float64_t dlgamma(float64_t x);
292
295  {
298
301  };
302
317
333
349
366
383  SGMatrix<float64_t> cov, int32_t N=1, bool precision_matrix=false);
384
401  SGSparseMatrix<float64_t> cov, int32_t N=1, bool precision_matrix=false);
402
404  static const float64_t ERFC_CASE1;
405
407  static const float64_t ERFC_CASE2;
408
409
410 };
411
413 template <>
414  inline floatmax_t CStatistics::mean<complex128_t>(SGVector<complex128_t> vec)
415  {
417  return floatmax_t(0.0);
418  }
419
420 }
421
422 #endif /* __STATISTICS_H_ */
static SGVector< int32_t > sample_indices(int32_t sample_size, int32_t N)
Definition: Statistics.cpp:325
static SGVector< float64_t > matrix_mean(SGMatrix< float64_t > values, bool col_wise=true)
Definition: Statistics.cpp:46
static SGVector< float64_t > matrix_std_deviation(SGMatrix< float64_t > values, bool col_wise=true)
Definition: Statistics.cpp:128
static float64_t lgamma(float64_t x)
Definition: Statistics.h:131
int32_t index_t
Definition: common.h:72
static float64_t std_deviation(SGVector< float64_t > values)
Definition: Statistics.cpp:123
static float64_t fdistribution_cdf(float64_t x, float64_t d1, float64_t d2)
Definition: Statistics.cpp:540
static SGVector< float64_t > fishers_exact_test_for_multiple_2x3_tables(SGMatrix< float64_t > tables)
Definition: Statistics.cpp:171
static float64_t relative_entropy(float64_t *p, float64_t *q, int32_t len)
Definition: Statistics.cpp:305
#define SG_SNOTIMPLEMENTED
Definition: SGIO.h:172
static const float64_t ERFC_CASE2
Definition: Statistics.h:407
static SGMatrix< float64_t > sample_from_gaussian(SGVector< float64_t > mean, SGMatrix< float64_t > cov, int32_t N=1, bool precision_matrix=false)
Definition: Statistics.cpp:706
static float64_t mutual_info(float64_t *p1, float64_t *p2, int32_t len)
Definition: Statistics.cpp:294
static float64_t log_det_general(const SGMatrix< float64_t > A)
Definition: Statistics.cpp:609
static float64_t gamma_cdf(float64_t x, float64_t a, float64_t b)
Definition: Statistics.cpp:398
static float64_t log_det(SGMatrix< float64_t > m)
Definition: Statistics.cpp:663
Class that contains certain functions related to statistics, such as probability/cumulative distribut...
Definition: Statistics.h:30
static float64_t lnormal_cdf(float64_t x)
Definition: Statistics.cpp:421
static float64_t tgamma(float64_t x)
Definition: Statistics.h:148
static SigmoidParamters fit_sigmoid(SGVector< float64_t > scores)
Definition: Statistics.cpp:824
static const float64_t ERFC_CASE1
Definition: Statistics.h:404
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:124
static float64_t entropy(float64_t *p, int32_t len)
Definition: Statistics.cpp:315
double float64_t
Definition: common.h:60
long double floatmax_t
Definition: common.h:61
virtual const char * get_name() const
Definition: Statistics.h:281
shogun vector
static SGMatrix< float64_t > covariance_matrix(SGMatrix< float64_t > observations, bool in_place=false)
Definition: Statistics.cpp:138
static floatmax_t mean(SGVector< T > vec)
Definition: Statistics.h:42
static float64_t inverse_normal_cdf(float64_t y0, float64_t mean=0, float64_t std_dev=1)
Definition: Statistics.cpp:351
static float64_t gamma_inverse_cdf(float64_t p, float64_t a, float64_t b)
Definition: Statistics.cpp:516
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
T sum(const Container< T > &a, bool no_diag=false)
static float64_t erfc8_weighted_sum(float64_t x)
Definition: Statistics.cpp:467
static float64_t dlgamma(float64_t x)
Definition: Statistics.cpp:561
static float64_t variance(SGVector< float64_t > values)
Definition: Statistics.cpp:32
static float64_t normal_cdf(float64_t x, float64_t std_dev=1)
Definition: Statistics.cpp:511
static float64_t fishers_exact_test_for_2x3_table(SGMatrix< float64_t > table)
Definition: Statistics.cpp:186
static float64_t chi2_cdf(float64_t x, float64_t k)
Definition: Statistics.cpp:377
static SGVector< float64_t > matrix_variance(SGMatrix< float64_t > values, bool col_wise=true)
Definition: Statistics.cpp:83
static floatmax_t lgammal(floatmax_t x)
Definition: Statistics.h:138
index_t vlen
Definition: SGVector.h:571

SHOGUN Machine Learning Toolbox - Documentation