Error bar on probability distribution function
조회 수: 14 (최근 30일)
이전 댓글 표시
Dear Matlab Community,
I have this set of data and I need to graph PDF and put error bars (std) on it. Would you please help me on this?
have written this for graphing PDF, but I do not know how to add error bar? or shaded error.
load ("diameter2.mat")
pd = fitdist(diameter_TAC','Kernel','Width',4);
x = 0:1:25;
y = pdf(pd,x);
z = plot(x,y,'k-','LineWidth',2);
Thank you !!
댓글 수: 0
채택된 답변
Vinay
2024년 9월 20일
편집: Vinay
2024년 9월 20일
Hi Neda,
The standard deviation represents the data spread around the mean and used to plot the error bar on the probability distribution plot by using the “errorbar” function. The standard deviation is used as the parameter for the errorbar height.
The code below shows the plotting of the error bars on the pdf plot:
data = diameter_TAC';
% Calculate the standard deviation of the data
std_dev = std(data);
% Plot the PDF
figure;
plot(x, y, 'k-', 'LineWidth', 2);
hold on;
% Add error bars
% plot them at each point of x.
errorbar(x, y, repmat(std_dev, size(x)), 'k.', 'LineWidth', 1);
Kindly refer to the below documentations of “repmat” and “errorbar” for more details:
댓글 수: 4
Vinay
2024년 9월 20일
The scale is to align the stds to the pdf value by scaling the stds value relative to the maximum value of the PDF. You can use the custom scaling factor to adjust the height.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Errorbars에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!