SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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-2012 Heiko Strathmann
8  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9  *
10  * ALGLIB Copyright 1984, 1987, 1995, 2000 by Stephen L. Moshier under GPL2+
11  * http://www.alglib.net/
12  * See method comments which functions are taken from ALGLIB (with adjustments
13  * for shogun)
14  */
15 
16 #ifndef __STATISTICS_H_
17 #define __STATISTICS_H_
18 
19 #include <math.h>
20 #include <shogun/lib/config.h>
21 #include <shogun/base/SGObject.h>
22 
23 namespace shogun
24 {
25 template<class T> class SGMatrix;
26 template<class T> class SGSparseMatrix;
27 
31 class CStatistics: public CSGObject
32 {
33 
34 public:
35 
42  static float64_t mean(SGVector<float64_t> values);
43 
70  static float64_t median(SGVector<float64_t> values, bool modify=false,
71  bool in_place=false);
72 
91  bool modify=false, bool in_place=false);
92 
101  static float64_t variance(SGVector<float64_t> values);
102 
112 
124  bool col_wise=true);
125 
139  bool col_wise=true);
140 
154  SGMatrix<float64_t> values, bool col_wise=true);
155 
156 #ifdef HAVE_LAPACK
157 
175  SGMatrix<float64_t> observations, bool in_place=false);
176 #endif //HAVE_LAPACK
177 
193  float64_t alpha, float64_t& conf_int_low, float64_t& conf_int_up);
194 
202  static float64_t inverse_student_t(int32_t k, float64_t p);
203 
216  float64_t y);
217 
241 
259 
262  float64_t std_dev);
263 
265  static inline float64_t lgamma(float64_t x)
266  {
267  return ::lgamma((double) x);
268  }
269 
272  static inline floatmax_t lgammal(floatmax_t x)
273  {
274 #ifdef HAVE_LGAMMAL
275  return ::lgammal((long double) x);
276 #else
277  return ::lgamma((double) x);
278 #endif // HAVE_LGAMMAL
279  }
280 
282  static inline float64_t tgamma(float64_t x)
283  {
284  return ::tgamma((double) x);
285  }
286 
304 
322 
332 
343 
359  float64_t y0);
360 
378  static float64_t normal_cdf(float64_t x, float64_t std_dev=1);
379 
395  static float64_t lnormal_cdf(float64_t x);
396 
404  static float64_t chi2_cdf(float64_t x, float64_t k);
405 
415 
422 
439 
455 
458  static float64_t mutual_info(float64_t* p1, float64_t* p2, int32_t len);
459 
463  float64_t* p, float64_t* q, int32_t len);
464 
466  static float64_t entropy(float64_t* p, int32_t len);
467 
472 
477 
482  static SGVector<int32_t> sample_indices(int32_t sample_size, int32_t N);
483 
485  virtual const char* get_name() const
486  {
487  return "Statistics";
488  }
489 
495  static float64_t dlgamma(float64_t x);
496 
499  {
502 
505  };
506 
521 
522 #ifdef HAVE_EIGEN3
523 
538 
554 
571 
588  SGMatrix<float64_t> cov, int32_t N=1, bool precision_matrix=false);
589 
606  SGSparseMatrix<float64_t> cov, int32_t N=1, bool precision_matrix=false);
607 #endif //HAVE_EIGEN3
608 
610  static const float64_t ERFC_CASE1;
611 
613  static const float64_t ERFC_CASE2;
614 
615 protected:
622  float64_t x, float64_t maxgam);
623 
629  float64_t x, float64_t big, float64_t biginv);
630 
636  float64_t x, float64_t big, float64_t biginv);
637 
639  static inline bool equal(float64_t a, float64_t b) { return a==b; }
640 
642  static inline bool not_equal(float64_t a, float64_t b) { return a!=b; }
643 
645  static inline bool less(float64_t a, float64_t b) { return a<b; }
646 
648  static inline bool less_equal(float64_t a, float64_t b) { return a<=b; }
649 
651  static inline bool greater(float64_t a, float64_t b) { return a>b; }
652 
654  static inline bool greater_equal(float64_t a, float64_t b) { return a>=b; }
655 };
656 
657 }
658 
659 #endif /* __STATISTICS_H_ */

SHOGUN Machine Learning Toolbox - Documentation