Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
include
osl
stat
probability.h
Go to the documentation of this file.
1
/* probability.h
2
*/
3
#ifndef _STAT_PROBABILITY_H
4
#define _STAT_PROBABILITY_H
5
6
#include <algorithm>
7
#include <cmath>
8
namespace
osl
9
{
10
namespace
stat
11
{
12
struct
Probability
13
{
14
unsigned
long
numerator
,
denominator
;
15
explicit
Probability
(
unsigned
long
n=0,
unsigned
long
d=0)
16
:
numerator
(n),
denominator
(d)
17
{
18
}
19
double
probability
(
double
stabilizer=1.0)
const
20
{
21
return
std::max
(stabilizer,
numerator
-stabilizer)
22
/
std::max
(stabilizer,static_cast<double>(
denominator
));
23
}
24
double
logProb
(
unsigned
int
stabilizer=1u)
const
25
{
26
const
double
prob =
probability
(stabilizer);
27
return
log(prob)/log(0.5)*100;
28
}
29
30
void
merge
(
const
Probability
& other)
31
{
32
numerator
+= other.
numerator
;
33
denominator
+= other.
denominator
;
34
}
35
};
36
}
// namespace stat
37
}
// namespace osl
38
39
#endif
/* _STAT_PROBABILITY_H */
40
// ;;; Local Variables:
41
// ;;; mode:c++
42
// ;;; c-basic-offset:2
43
// ;;; End:
44
45
Generated on Sun Jul 21 2013 13:37:26 by
1.8.4