Perl-Sensitive Sunglasses PerlMonks

### Comment on

 Need Help??
By inversely proportional, I meant that the number of questions asked to identify an animal (Q) multiplied by how many times the animal is chosen (C) should be constant. If a goat appears a hundred times more often than a unicorn then it should take a hundred times more questions to identify the unicorn than the goat.

In roboticus' example, which you seem to be endorsing, this is the tree produced:

```                                             Q
___________________/ \___________________
/                                         \
Q                         __________________Q
/ \                       /                   \
Q   fish                  Q            _________Q
/ \                       / \          /
+\
__________Q   cow                 dog   cat      Q
+ Q
/           \                                    / \
+/ \
Q             Q                                  Q   wolf sheep
+   horse
/ \           / \                                / \
walrus   badger seal   Q________________      wolverine   frog
/                 \
Q                   Q
/ \                 / \
Q   hampster   ocolot   Q
/ \                     / \
pegasus   Q              gerbil   platypus
/ \
axolotl   unicorn

The fish with a frequency of 150 requires 2 questions; the unicorn with a frequency of 1, required 9. And it puts walrus(15), badger(17), seal(18), wolverine(22) & frog(28) at the same level.

So the inverse proportionality is relative rather than mathematically absolute. It would require the insertion of 291 additional questions above the unicorn to achieve the math you describe, and in the process, throws away the "compressive" attribute that defines Huffman.

If non-compressive, relative inverse proportionality is sufficient, then my original reading of your question would be more accurate:

```     Q
/ \
fish   Q
/ \
cat   Q
/ \
dog   Q
/ \
cow   Q
/ \
horse   Q
/ \
sheep   Q
/ \
wolf   Q
/ \
frog   Q
/ \
wolverine   Q
/ \
seal   Q
/ \
/ \
walrus   Q
/ \
ocelot   Q
/ \
hamster   Q
/ \
gerbil   Q
/ \
platypus   Q
/ \
unicorn   Q
/ \
pegasus   axolotl

Which brings me back to the idea that what roboticus' use of Huffman does, is minimise the depth of the tree.

But if that were the goal, then its maximum depth of 9 is 3 more than is required:

```
__________Q__________
/                     \
fish   ____________________Q______________________
/                                           \
Q                    _________________________Q_________________
+__________
/ \                  /
+          \
cat dog      _________Q__________                                __
+___________Q_______________
/                    \                              /
+                           \
____Q____             _____Q______                 _____Q___
+___                   ______Q______
/         \           /            \               /
+   \                 /             \
Q           Q         Q              Q             Q
+    Q               Q               Q
/ \         / \       / \            / \           / \
+   / \             / \             / \
cow horse sheep wolf frog wolverine seal badger walrus ocelot ham
+ster gerbil platypus unicorn pegasus axolotl

All of which I guess means, that I have no idea what you set out to achieve :(

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
• Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
• You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
 For: Use: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
 [1nickt]: erix Darwin doesn't apply no more: BBC - Caesarean births affecting human evolution [erix]: TLDR - but I don't believe it ;)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2017-10-17 15:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My fridge is mostly full of:

Results (233 votes). Check out past polls.

Notices?