How can I calculate the entropy of a random signal using its histogram?
26 次查看(过去 30 天)
显示 更早的评论
I have a random signal X and I want to calculate the entropy. I don't know how to calculate the probability for each bin. I assigned below the code I did in order to generate the signal and also to calculate the numbers of bins.
X=rand(50,1)
k=1+log2(50) %Computing the number of bins
bins=round(k)
n=hist(X,bins)
1 个评论
shafiqah yusoff
2017-12-17
just want to ask. can you please elaborate more the function of X, bins ,and n.? thank you
回答(2 个)
Image Analyst
2013-10-29
Don't you just add on this code:
p = n / sum(n)
entropy = -sum(p .*log(p))
or am I overlooking something???
0 个评论
Marcin
2017-5-30
In Matlab R2016b (and maybe earlier) you can use entropy function. The only thing you should remember is that it is designed for image processing, therefore you have to normalize a signal before calling entropy:
x_normalized = x/max(abs(x));
e = entropy(x_normalized)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Histograms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!