-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsampling.h
56 lines (33 loc) · 1.04 KB
/
sampling.h
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
#ifndef _SAMPLING
#define _SAMPLING
#include "zipf.h"
using namespace std;
/*
Generic interface for sampling from a relation maintained as tuples.
*/
class Sampling {
public:
vector<unsigned int> *sample;
Sampling();
virtual ~Sampling();
virtual void Build_Sample(Zipf *relation) = 0;
//dot product or size of join of two samples, and estimation
virtual double Dot_Product(Sampling *s);
virtual double Dot_Product_Estimation(Sampling *s) = 0;
virtual double Scale_Dot_Product_Estimate(Sampling *s, double est) = 0;
};
/*
Bernoulli sampling with probability p.
an element is sampled if its probability (randomly generated) is smaller than p;
So, if p = 1.0, everyone is sampled, while for p = 0.0 nobody gets into the sample.
*/
class Bernoulli_Sampling : public Sampling {
public:
double p;
Bernoulli_Sampling(double p);
virtual ~Bernoulli_Sampling();
virtual void Build_Sample(Zipf *relation);
virtual double Dot_Product_Estimation(Sampling *s);
virtual double Scale_Dot_Product_Estimate(Sampling *s, double est);
};
#endif