How to integral a pdf of a continuous random variable to calculate its entropy
2 ビュー (過去 30 日間)
古いコメントを表示
Hi guys,
I'm trying to figure out how to get the entropy of a probability distribution. It's the standard differential entropy and the formula is:
, where
is the probability denstiy function.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/527419/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/527424/image.png)
I have referred to integral function q = integral(fun,xmin,xmax) I'm confused how to define this fun? For instance, I'm dealing with Beta distribution and I have used the following code for its pdf. However, this y is just the evaluated values of x, not exactly a fun. I suppose I can't use this y directly. So, is there a way that I can create or transfer y to a fun that I can apply with integral? Please help me with it. Thanks in advance!
pd = makedist('beta','a',50,'b',40)
x = linspace(0,1,10000);
y = pdf(pd,x);
0 件のコメント
採用された回答
Jeff Miller
2021 年 2 月 22 日
編集済み: Jeff Miller
2021 年 2 月 22 日
Try this:
pd = makedist('beta','a',50,'b',40);
fun = @(x) pdf(pd,x) .* log( pdf(pd,x) );
H = -integral(fun,0,1)
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!