5 ms·
Your math is wrong. If two of the numbers happen to be the same, order no longer matters for those numbers, so your log2(4!) needs to be larger...
by londons_explore 9y ago
Your math is wrong.
If two of the numbers happen to be the same, order no longer matters for those numbers, so your log2(4!) needs to be larger...
- jack9 9y agoThe maximum entropy is what is important, to the encoding challenge, as I understood it.
- deleted 9y ago[deleted]
- deleted 9y ago[deleted]
- deleted 9y ago[deleted]
- scatters 9y agoRight. So the true answer is log2((32*31*30*29)/(4*3*2) + (32*31*30)/2 + (32*31) + (32*31)/2) = 15.675 which is still smaller than 16.
- yorwba 9y agoAre you sure you don't mean log2((32*31*30*29)/(4*3*2*1) + (32*31*30)/(3*2*1) + (32*31)/(2*1) + 32/1) = 15.34 using the number of sets of values from {0, 2^5-1} with at most 4 elements? If on the other hand you want to store exactly 4 values, possibly with duplicates (while still ignoring order), you need to count multisets ( https://en.wikipedia.org/wiki/Bag_(mathematics)#Counting_multisets https://en.wikipedia.org/wiki/Bag_(mathematics)#Counting_mul... ) log2( (35*34*33*32)/(4*3*2*1) ) = 15.676
- pishpash 9y agoThe second answer, 15.676, is the correct one. It can also be arrived at by: log2(32C4 + 32C3 * 3 + 32C2 * 3 + 32C1)
- bubblethink 9y agoI followed the original link as well as this calculation. Why not use this to map them directly (instead of breaking it into 12 bits and 4 bits) ? We'll just have some unused headroom in 16 bits. This would seem more natural than thinking of the 12 + 4 solution.
- bonzini 9y agoIt uses more memory.
- bonzini 9y agoWhat the parent message did is: log2(32+4-1 C 4), because the number of k-sized combinations of n objects with repetitions is (n+k-1)Ck. One way to prove it is that you sort the objects (so you can establish an order among the objects in the combination) and add k-1 dummy objects for "the second is the same as the first, the third is the same as the second,..., the last is the same as the penultimate".
- mturmon 9y agoHis math is right. The factorial already took care of the fact that order does not matter. If you want to optimize storage of duplicates, you still have to store the number of duplicate numbers, and you are back where you started.
- yorwba 9y agoThe factorial is taking too much care of the fact that order does not matter. If I wanted to store four 1-bit numbers, ajkjk's math would suggest that I need log2(2^4/4!) = -0.58, i.e. a negative number of bits. You can't just divide by 4! because not all combinations of 4 numbers have 4! unique permutations. > If you want to optimize storage of duplicates, you still have to store the number of duplicate numbers, and you are back where you started. No, because you can shave off a few bits by ignoring the ordering of the non-duplicates.
- mturmon 9y agoYou’re right, correction appreciated.
- pishpash 9y agoActually the log2(4!) needs to be smaller, because as yorwba below says, duplicates don't have 24 permutations.
- rcthompson 9y agoDoes this implementation allow duplicates? Typically a set is defined as an unordered collection with no duplicate items.