Function File: riceenco (sig, K)

Returns the Rice encoded signal using K or optimal K . Default optimal K is chosen between 0-7. Currently no other way to increase the range except to specify explicitly. Also returns K parameter used (in case it were to be chosen optimally) and Ltot the total length of output code in bits. This function uses a K if supplied or by default chooses the optimal K for encoding signal vector into a rice coded vector. A restrictions is that a signal set must strictly be non-negative. The Rice algorithm is used to encode the data into unary coded quotient part which is represented as a set of 1’s separated from the K-part (binary) using a zero. This scheme doesn’t need any kind of dictionaries and its close to O(N), but this implementation *may be* sluggish, though correct.

Reference: Solomon Golomb, Run length Encodings, 1966 IEEE Trans Info’ Theory

An example of the use of riceenco is

riceenco (1:4)
    ⇒ {[0 1], [1 0 0], [1 0 1], [1 1 0 0]}
riceenco (1:10, 2)
    ⇒ {[0 0 1], [0 1 0], [0 1 1], [1 0 0 0],
        [1 0 0 1], [1 0 1 0], [1 0 1 1], [1 1 0 0 0],
        [1 1 0 0 1], [1 1 0 1 0]}

See also: ricedeco.

Package: communications