MCPcopy Create free account
hub / github.com/Stream-AD/MIDAS / NormalCore

Class NormalCore

src/NormalCore.hpp:24–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22
23namespace MIDAS {
24struct NormalCore {
25 int timestamp = 1;
26 int* const index; // Pre-compute the index to-be-modified, thanks to the same structure of CMSs
27 CountMinSketch numCurrent, numTotal;
28
29 NormalCore(int numRow, int numColumn):
30 index(new int[numRow]),
31 numCurrent(numRow, numColumn),
32 numTotal(numCurrent) { }
33
34 virtual ~NormalCore() {
35 delete[] index;
36 }
37
38 static float ComputeScore(float a, float s, float t) {
39 return s == 0 || t - 1 == 0 ? 0 : pow((a - s / t) * t, 2) / (s * (t - 1));
40 }
41
42 float operator()(int source, int destination, int timestamp) {
43 if (this->timestamp < timestamp) {
44 numCurrent.ClearAll();
45 this->timestamp = timestamp;
46 }
47 numCurrent.Hash(index, source, destination);
48 numCurrent.Add(index);
49 numTotal.Add(index);
50 return ComputeScore(numCurrent(index), numTotal(index), timestamp);
51 }
52};
53}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected