-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDstatCounter.cpp
78 lines (57 loc) · 1.92 KB
/
DstatCounter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* DstatCounter
* Date: Oct-15-2012
* Author : Gabriel Renaud gabriel.reno@gmail.com
*
*/
#include "DstatCounter.h"
DstatCounter::DstatCounter(){
reinitializedCounters();
}
void DstatCounter::reinitializedCounters(){
counterAncAnc =0;
counterAncDer =0;
counterDerAnc =0;
counterDerDer =0;
}
string DstatCounter::headerForCount() const {
return "AA\tAD\tDA\tDD\t(ADDA-DADA)/(ADDA+ADDA)";
}
// vector<double> DstatCounter::performBoostraps() const{
// vector<double> boostraps;
// timeval time;
// gettimeofday(&time, NULL);
// srand( long((time.tv_sec * 1000) + (time.tv_usec / 1000)) );
// unsigned int sumADDA = (counterDerAnc+counterAncDer);
// for(unsigned int i=0;i<1000;i++){
// unsigned int counterAncDerBoot=0;
// unsigned int counterDerAncBoot=0;
// for(unsigned int j=0;j<(sumADDA);j++){
// unsigned int randnum = rand()%sumADDA;
// if(randnum<counterAncDer)
// counterAncDerBoot++;
// else
// counterDerAncBoot++;
// }
// boostraps.push_back( (double(counterAncDerBoot)-double(counterDerAncBoot))/(double(counterAncDerBoot)+double(counterDerAncBoot)) );
// }
// return boostraps;
// }
double DstatCounter::computeDST() const{
double dst= (double(counterAncDer)-double(counterDerAnc))/(double(counterAncDer)+double(counterDerAnc));
return dst;
}
DstatCounter & DstatCounter::operator+=(const DstatCounter & other){
this->counterAncAnc += other.counterAncAnc;
this->counterAncDer += other.counterAncDer;
this->counterDerAnc += other.counterDerAnc;
this->counterDerDer += other.counterDerDer;
return *this;
}
DstatCounter & DstatCounter::operator-=(const DstatCounter & other){
this->counterAncAnc -= other.counterAncAnc;
this->counterAncDer -= other.counterAncDer;
this->counterDerAnc -= other.counterDerAnc;
this->counterDerDer -= other.counterDerDer;
return *this;
}