Entropy calculation at base 10
5 ビュー (過去 30 日間)
古いコメントを表示
I use pentropy function to calculate entropy of a discrete signal.
The function calculates the entropy at base 2 (Shannon information theory).
Is there a way to calculate it at base 10 rather than 2?
0 件のコメント
採用された回答
John D'Errico
2020 年 8 月 26 日
編集済み: John D'Errico
2020 年 8 月 26 日
Um, think about what entropy means, at least in a mathematical form. It is just a logarithm.
So all you are asking is to compute a log to some other base.
To convert between different bases of a log is simple. Thus if we define a TWO parameter log function as:
log(x,B)
as the log of x, to base B, we can easily convert between bases, or more simple, relate the log for any base to the natural log. Here, I'll use log(x) as the natural log of x, some prefer ln as the natual log, but to be consistent with MATLAB notation, just use log. The basic formula is:
log(x,B) = log(x)/log(B)
Again, that one parameter log is just the natural log. This also means if we want to convert from one logarithmic base to another, you have a simple formula, since we would have
log(x) = log(x,B)*log(B) = log(x,A)*log(A)
And that gives us the base change formula directly.
log(x,A) = log(x,B)*log(B)/log(A)
We can test this easily enough in MATLAB, in case you don't believe me. MATLAB provides the functinos long2 and log10. That is, I can compute the log(3), to the base 2. From that, can I now convert it to the log(3) to base 10?
log2(3)
ans =
1.58496250072116
Just use the formula I showed:
log2(3)*log(2)/log(10)
ans =
0.477121254719662
log10(3)
ans =
0.477121254719662
As you should see, both give the same result.
So if you wish to convert an entropy computation from one base to another, multiply by the ratio of the natural logs of the two bases.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!