forked from hxim/paq8px
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPredictor.hpp
47 lines (41 loc) · 1.07 KB
/
Predictor.hpp
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
#ifndef PAQ8PX_PREDICTOR_HPP
#define PAQ8PX_PREDICTOR_HPP
#include "file/FileDisk.hpp"
#include "DummyMixer.hpp"
#include "Models.hpp"
#include "SSE.hpp"
#include "Shared.hpp"
#include "UpdateBroadcaster.hpp"
#include "file/OpenFromMyFolder.hpp"
#include "model/ContextModel.hpp"
#include "model/ExeModel.hpp"
#include "model/NormalModel.hpp"
#include "model/WordModel.hpp"
#include "utils.hpp"
/**
* A Predictor estimates the probability that the next bit of uncompressed data is 1.
*/
class Predictor {
private:
Shared *shared;
Models *models;
ContextModel *contextModel;
SSE sse;
int pr; // next prediction, scaled by 12 bits (0-4095)
void trainText(const char *dictionary, int iterations);
void trainExe();
public:
Predictor(Shared* const sh);
~Predictor();
/**
* Returns P(1) as a 12 bit number (0-4095).
* @return the prediction
*/
[[nodiscard]] auto p() -> int;
/**
* Trains the models with the actual bit (0 or 1).
* @param y the actual bit
*/
void update(uint8_t y);
};
#endif //PAQ8PX_PREDICTOR_HPP