필터 지우기
필터 지우기

how can I create a plot with box the density function of a normal distribution and a log normal distribution

조회 수: 4 (최근 30일)
I would like to have both:
a) a plot with the density function of a normal distributed random variable and the densitiy function of a log-normal distributed random variabel
b) a plot with the densitiy function of a normal distributed random variable and the density function of a t-distributed random variable for several degrees of freedom

채택된 답변

Tom Lane
Tom Lane 2013년 3월 27일
You could simply use the normpdf, lognpdf, and tpdf function to compute these densities, and plot the results together.
If you need to fit the distributions to data, here's an example that might get you started:
x = wblrnd(10,2,1000,1);
[heights,centers] = hist(x,40);
area = (centers(2)-centers(1))*sum(heights);
bar(centers,heights/area,'hist') % normalize histogram to integrate to 1
p1 = fitdist(x,'normal'); % fit three distributions
p2 = fitdist(x,'lognormal');
p3 = fitdist(x,'tlocationscale');
xx = linspace(0,30);
line(xx,pdf(p1,xx),'color','r') % plot three densities
line(xx,pdf(p2,xx),'color','g')
line(xx,pdf(p3,xx),'color','m')
  댓글 수: 3
Tom Lane
Tom Lane 2013년 4월 1일
You can omit lines 2-4 (hist/area/bar) if you don't want the densities superimposed on a histogram.

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by