Let us consider following code:

Code:

**class** TPredictor {
**private:**
**unsigned short** pr;
**public:
**TPredictor(): pr(2048) {}
** i****nt **P() {
**return **(pr);
}
**void **Update(**int **y) {
**if **(y)
pr+=((4095-pr)>>5);
**else**
pr-=(pr>>5);
}
};

This is a FPAQ0P-styled predictor that predicts the probability of a one bit.

And here is a modification a la FPAQ0M:

Code:

**class** TPredictor {
**private:**
** unsigned short** p1;
** unsigned short** p2;
**public:
** TPredictor(): p1(2048), p2(2048) {}
**int **P() {
**return **((p1+p2)>>1);
}
**void **Update(**int **y) {
**if **(y) {
p1+=((4095-p1)>>3);
p2+=((4095-p2)>>6);
}**
else** {
p1-=(p1>>3);
p2-=(p2>>6);
}
}
};

For comparison, here is a classical example of stationary/non-stationary (semi-stationary) predictor:

Code:

**class** TPredictor {
**private:**
**unsigned char** n0;
**unsigned char **n1;
**public:
** TPredictor(): n0(0), n1(0) {}
**int **P() {
**return **(((n1+1)<<12)/((n0+n1)+2));
}
**void **UpdateStationary(**int **y) {
**if **(y) {
**if **(++n1>=255) {
n0>>=1;
n1>>=1;
}
} **
else **{
**if **(++n0>=255) {
n0>>=1;
n1>>=1;
}
}
}
**void **UpdateNonStationary(**int **y) {
**if **(y) {
**if** (n1<255) n1++;
**if** (n0>2) n0=(n0>>1)+1;
} **
else **{
**if** (n0<255) n0++;
**if** (n1>2) n1=(n1>>1)+1;
}
}
};

The question is ? how we can add a SSE/weighed mixing inside this class ? i.e. no additional tables, no additional classes ? all stuff inside one class. The second example needs four bytes per bit prediction; I think we may use eight bytes ? i.e. we may add one more 32-bit integer or two 16-bit integers, etc. What we possibly can:

+ Add weighed mixing of both probabilities (fast and slow ones)

+ Add weighed mixing of one or two probabilities with static model (prob. = 0.5)

+ Add kind of SSE/APM inside

Any ideas/suggestions?