SHOGUN  v3.0.0
 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 
413 
429 
432  static float64_t mutual_info(float64_t* p1, float64_t* p2, int32_t len);
433 
437  float64_t* p, float64_t* q, int32_t len);
438 
440  static float64_t entropy(float64_t* p, int32_t len);
441 
446 
451 
456  static SGVector<int32_t> sample_indices(int32_t sample_size, int32_t N);
457 
459  virtual const char* get_name() const
460  {
461  return "Statistics";
462  }
463 
469  static float64_t dlgamma(float64_t x);
470 
473  {
476 
479  };
480 
495 
496 #ifdef HAVE_EIGEN3
497 
512 
529 
546  SGMatrix<float64_t> cov, int32_t N=1, bool precision_matrix=false);
547 
564  SGSparseMatrix<float64_t> cov, int32_t N=1, bool precision_matrix=false);
565 #endif //HAVE_EIGEN3
566 
567 
568 protected:
575  float64_t x, float64_t maxgam);
576 
582  float64_t x, float64_t big, float64_t biginv);
583 
589  float64_t x, float64_t big, float64_t biginv);
590 
592  static inline bool equal(float64_t a, float64_t b) { return a==b; }
593 
595  static inline bool not_equal(float64_t a, float64_t b) { return a!=b; }
596 
598  static inline bool less(float64_t a, float64_t b) { return a<b; }
599 
601  static inline bool less_equal(float64_t a, float64_t b) { return a<=b; }
602 
604  static inline bool greater(float64_t a, float64_t b) { return a>b; }
605 
607  static inline bool greater_equal(float64_t a, float64_t b) { return a>=b; }
608 };
609 
610 }
611 
612 #endif /* __STATISTICS_H_ */

SHOGUN Machine Learning Toolbox - Documentation