SHOGUN
v2.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
mathematics
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
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
89
static
float64_t
matrix_median
(
SGMatrix<float64_t>
values,
90
bool
modify=
false
,
bool
in_place=
false
);
91
100
static
float64_t
variance
(
SGVector<float64_t>
values);
101
110
static
float64_t
std_deviation
(
SGVector<float64_t>
values);
111
122
static
SGVector<float64_t>
matrix_mean
(
SGMatrix<float64_t>
values,
123
bool
col_wise=
true
);
124
137
static
SGVector<float64_t>
matrix_variance
(
SGMatrix<float64_t>
values,
138
bool
col_wise=
true
);
139
152
static
SGVector<float64_t>
matrix_std_deviation
(
153
SGMatrix<float64_t>
values,
bool
col_wise=
true
);
154
155
#ifdef HAVE_LAPACK
156
173
static
SGMatrix<float64_t>
covariance_matrix
(
174
SGMatrix<float64_t>
observations,
bool
in_place=
false
);
175
#endif //HAVE_LAPACK
176
191
static
float64_t
confidence_intervals_mean
(
SGVector<float64_t>
values,
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
214
static
float64_t
inverse_incomplete_beta
(
float64_t
a,
float64_t
b,
215
float64_t
y);
216
239
static
float64_t
incomplete_beta
(
float64_t
a,
float64_t
b,
float64_t
x);
240
257
static
float64_t
inverse_normal_cdf
(
float64_t
y0);
258
260
static
float64_t
inverse_normal_cdf
(
float64_t
y0,
float64_t
mean,
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
302
static
float64_t
incomplete_gamma
(
float64_t
a,
float64_t
x);
303
320
static
float64_t
incomplete_gamma_completed
(
float64_t
a,
float64_t
x);
321
330
static
float64_t
gamma_cdf
(
float64_t
x,
float64_t
a,
float64_t
b);
331
341
static
float64_t
inverse_gamma_cdf
(
float64_t
p,
float64_t
a,
float64_t
b);
342
357
static
float64_t
inverse_incomplete_gamma_completed
(
float64_t
a,
358
float64_t
y0);
359
377
static
float64_t
normal_cdf
(
float64_t
x,
float64_t
std_dev=1);
378
394
static
float64_t
error_function
(
float64_t
x);
395
410
static
float64_t
error_function_complement
(
float64_t
x);
411
414
static
float64_t
mutual_info
(
float64_t
* p1,
float64_t
* p2, int32_t len);
415
418
static
float64_t
relative_entropy
(
419
float64_t
* p,
float64_t
* q, int32_t len);
420
422
static
float64_t
entropy
(
float64_t
* p, int32_t len);
423
427
static
SGVector<float64_t>
fishers_exact_test_for_multiple_2x3_tables
(
SGMatrix<float64_t>
tables);
428
432
static
float64_t
fishers_exact_test_for_2x3_table
(
SGMatrix<float64_t>
table);
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
:
463
static
float64_t
ibetaf_incompletebetaps
(
float64_t
a,
float64_t
b,
464
float64_t
x,
float64_t
maxgam);
465
470
static
float64_t
ibetaf_incompletebetafe
(
float64_t
a,
float64_t
b,
471
float64_t
x,
float64_t
big,
float64_t
biginv);
472
477
static
float64_t
ibetaf_incompletebetafe2
(
float64_t
a,
float64_t
b,
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