SHOGUN  v2.0.0
Statistics.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
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
30 class CStatistics: public CSGObject
31 {
32
33 public:
34
41  static float64_t mean(SGVector<float64_t> values);
42
69  static float64_t median(SGVector<float64_t> values, bool modify=false,
70  bool in_place=false);
71
90  bool modify=false, bool in_place=false);
91
100  static float64_t variance(SGVector<float64_t> values);
101
111
123  bool col_wise=true);
124
138  bool col_wise=true);
139
153  SGMatrix<float64_t> values, bool col_wise=true);
154
155 #ifdef HAVE_LAPACK
156
174  SGMatrix<float64_t> observations, bool in_place=false);
175 #endif //HAVE_LAPACK
176
192  float64_t alpha, float64_t& conf_int_low, float64_t& conf_int_up);
193
201  static float64_t inverse_student_t(int32_t k, float64_t p);
202
215  float64_t y);
216
240
258
261  float64_t std_dev);
262
264  static inline float64_t lgamma(float64_t x)
265  {
266  return ::lgamma((double) x);
267  }
268
271  static inline floatmax_t lgammal(floatmax_t x)
272  {
273 #ifdef HAVE_LGAMMAL
274  return ::lgammal((long double) x);
275 #else
276  return ::lgamma((double) x);
277 #endif // HAVE_LGAMMAL
278  }
279
281  static inline float64_t tgamma(float64_t x)
282  {
283  return ::tgamma((double) x);
284  }
285
303
321
331
342
358  float64_t y0);
359
377  static float64_t normal_cdf(float64_t x, float64_t std_dev=1);
378
395
411
414  static float64_t mutual_info(float64_t* p1, float64_t* p2, int32_t len);
415
419  float64_t* p, float64_t* q, int32_t len);
420
422  static float64_t entropy(float64_t* p, int32_t len);
423
428
433
438  static SGVector<int32_t> sample_indices(int32_t sample_size, int32_t N);
439
441  inline virtual const char* get_name() const
442  {
443  return "Statistics";
444  }
445
454  static float64_t dlgamma(float64_t x);
455
456
457 protected:
464  float64_t x, float64_t maxgam);
465
471  float64_t x, float64_t big, float64_t biginv);
472
478  float64_t x, float64_t big, float64_t biginv);
479
481  static inline bool equal(float64_t a, float64_t b) { return a==b; }
482
484  static inline bool not_equal(float64_t a, float64_t b) { return a!=b; }
485
487  static inline bool less(float64_t a, float64_t b) { return a<b; }
488
490  static inline bool less_equal(float64_t a, float64_t b) { return a<=b; }
491
493  static inline bool greater(float64_t a, float64_t b) { return a>b; }
494
496  static inline bool greater_equal(float64_t a, float64_t b) { return a>=b; }
497 };
498
499 }
500
501 #endif /* __STATISTICS_H_ */

SHOGUN Machine Learning Toolbox - Documentation