--------------------------------------------------------------------------- Re: stretch/squash LUT computing - stretch() is computed from squash() in paq and derivatives. But how should it normally work? Let's compute stretch() first, with enough precision. But then we want a very limited number of values on squash output, and we know the specific values for corresponding squash inputs (-n..n), so we can list the values in the precise stretch table, matching these inputs, Now a question: what value should we use for squash(x), when we known that a probability range p1..p2 matches x? The error cost when it should be p, but squash(x) gives q is (-p*log2(q)-(1-p)*log2(1-q)) - (-p*log2(p)-(1-p)*log2(1-p)) And we have such an error for all probabilities in range p1..p2, so it has to be summed and minimized by q. D[ Sum[ p*Log[2,q/p] + (1-p)*Log[2,(1-q)/(1-p)], {p, p1, p2}] ,q] Solve[((p1-p2-1)*(p1+p2-2*q))/(2*q*(q-1)*Log[2])==0,q] -> q=(p1+p2)/2 Well, this is rather nice and simple, but isn't it different from how paq stretch/squash init works?