How i can plot the entropy function H(p1,p2,p3) for three vector of probability p1, p2 and p3= (1-p1-p2)

조회 수: 22 (최근 30일)
hello every one.
How i can plot the entropy function H(p1,p2,p3) for three vector of probability p1, p2 and p3= (1-p1-p2) ... I tried this script but it seems to be wrong! could any one help me plz Many Thanks
clear all
clc
p_0=[0:0.01:0.5];
p_1=[0:0.01:0.5];
[P_0,P_1] = meshgrid(p_0,p_1);
H = (-P_0.*log2(P_0)-(P_1).*log2(P_1)-(1-P_0-P_1).*log2((1-P_0-P_1)));
surf(P_0,P_1,H)
  댓글 수: 3
Tammun filistin
Tammun filistin 2018년 5월 7일
편집: Tammun filistin 2018년 5월 7일
the correct answer supposed to be as the attached page from "Information Theory Jan C. A. van der Lubbe"

댓글을 달려면 로그인하십시오.

채택된 답변

Ameer Hamza
Ameer Hamza 2018년 5월 7일
Your formula does not include the term -(1-P_0-P_1).*log2((1-P_0-P_1)), For 2D case, you can get something similar using this.
clear all
clc
p_0=0:0.01:1;
p_1=0:0.01:1;
[P_0,P_1] = meshgrid(p_0,p_1);
H = -P_0.*log2(P_0)-(P_1).*log2(P_1);
contour(P_0,P_1, H, 'ShowText', 'on')
  댓글 수: 1
Tammun filistin
Tammun filistin 2018년 5월 7일
im using 3 outcome probabilities which is p_0,p_1,p2=1-p_0-p_1 thats why im using this -(1-P_0-P_1).*log2((1-P_0-P_1)). Thank you

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Communications Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by