Talk:Rice coding: Difference between revisions

From Rosetta Code
Content added Content deleted
mNo edit summary
Line 3: Line 3:


Ricde coding is apparently a compression technique, but inspecting the <code>encode</code> implementation, I see <code>($n mod $d).polymod(2 xx $k - 1).reverse</code> which probably means that the encoded number would have at least as many bits as the value of the number being encoded. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 12:03, 21 September 2023 (UTC)
Ricde coding is apparently a compression technique, but inspecting the <code>encode</code> implementation, I see <code>($n mod $d).polymod(2 xx $k - 1).reverse</code> which probably means that the encoded number would have at least as many bits as the value of the number being encoded. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 12:03, 21 September 2023 (UTC)

:The technique is useful if you are transmitting bits in a continuous stream. If you simply use binary representation the each number has to take a fixed number of bits, say 32 or 64. This coding allows you to use a variable number of bits for each number while still knowing where each number starts and stops. The number of bits used depends on the value of m chosen. As you note the original post came with no examples, so different submissions have used different values with different results. F# uses m=16, probably better if all solutions used the same m or ms.--[[User:Nigel Galloway|Nigel Galloway]] ([[User talk:Nigel Galloway|talk]]) 14:05, 21 September 2023 (UTC)

Revision as of 14:05, 21 September 2023

No examples?

It's difficult to tell whether the current implementation here is correct.

Ricde coding is apparently a compression technique, but inspecting the encode implementation, I see ($n mod $d).polymod(2 xx $k - 1).reverse which probably means that the encoded number would have at least as many bits as the value of the number being encoded. --Rdm (talk) 12:03, 21 September 2023 (UTC)

The technique is useful if you are transmitting bits in a continuous stream. If you simply use binary representation the each number has to take a fixed number of bits, say 32 or 64. This coding allows you to use a variable number of bits for each number while still knowing where each number starts and stops. The number of bits used depends on the value of m chosen. As you note the original post came with no examples, so different submissions have used different values with different results. F# uses m=16, probably better if all solutions used the same m or ms.--Nigel Galloway (talk) 14:05, 21 September 2023 (UTC)