How to plot histogram of a given pdf

조회 수: 6 (최근 30일)
Sudhir Sahoo
Sudhir Sahoo 2021년 5월 7일
댓글: Sudhir Sahoo 2021년 5월 7일
For a given distribution fucntion of z pdf is defined as ,, where β is the beta fuction and m, are constant. How to plot it in histogram in matlab. Should I choosed Z randomly? How to plots its histogram.

채택된 답변

William Rose
William Rose 2021년 5월 7일
Here is a script that evaluates the density.
Are there restrictions on what the allowed values are for m?
Your formula gives density= at z=0. It gives complex numbers for z<0, for most values of m. That makes me wonder if the formula is really correct.
%SudhirsDensity.m
%WCR 2021-05-07
zmax=1;
re=1;
m=0;
z=(-20:1:20)*zmax/20;
f=zeros(length(z),1);
k=2*beta((m+4)/(2*m+4),0.5)/(pi*(m+2)*re^2);
for i=1:length(z)
f(i)=k*z(i)^(-(m+4)/(m+2));
end
plot(z,f);
xlabel('z');
ylabel('density');
If you want a random sample, then you would need to know the inverse of the distribution function. The you could draw a random number, p, from U[0,1) and then find the inverse from the inverse distribution function. That is the z value corresponding to point p on the distribution. Do that many times. Then you can plot the histogram of the z values you have obtained. But you can't do any of that, because you do not have the inverse distribution function for this density.
  댓글 수: 1
Sudhir Sahoo
Sudhir Sahoo 2021년 5월 7일
@William Rose Yes you are correct at z = 0 pdf is coming , for a positive value of m too. As this is a product distribution of where and . Thanks for your help and time.

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by