How to show with a line/arrow the center/one/two standard deviation of the normal distribution plot?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have plotted a normal distribution plot with Mean=0.34, and now would like to show the center, which is 0.34 and show two standard deviation with colorful lines or arrows.
Let’s say I have Mean=0.34, so next line I would like to show 0.37 on the right hand side, and on the left hand side 0.306. This would be 68%; and now have to show for 95%, which is 0.404 (right hand side) and 0.272 (left hand side)
I would like to plot something like this that shows the center (mean) and 2 standard deviations on the sides i.e. 68% and 95% (please see below):
댓글 수: 0
답변 (1개)
Joseph Cheng
2015년 10월 6일
편집: Joseph Cheng
2015년 10월 6일
would something like this work?
x = .03*randn(10000,1)+.34;
[N,X] = hist(x,100);
hfig = figure;
bar(X,N)
hold on;
y = [0 1.2*max(N)];
center = mean(x);
std1 = std(x);
%center plot
plot([center center],y,'r-.')
%1 std
plot([center center]+std1,y,'g-.')
plot([center center]-std1,y,'g-.')
%2 std
plot([center center]+2*std1,y,'k-.')
plot([center center]-2*std1,y,'k-.')
댓글 수: 4
Joseph Cheng
2015년 10월 6일
편집: Joseph Cheng
2015년 10월 6일
I don't know what you mean? wouldn't plot(X,N) work? Everything up to hold on was just my dummy data set to get roughly what you explained. That is my data, what does your data look like, what exactly is your mean and std for plotting. The left and right hand sigma aren't symmetric where as mine are.
Sunshine
2020년 5월 20일
I can calculate the mean and standard deviations for my data. However, I want to plot a bell curve using the calculated mean and standard deviations (out to 3sigma), including my data to show where the data falls on the bell curve. How do I include my data in this code? Also, in the following lines, I'm not quite following what's happening (I think I understand the other lines). Would you please explain:
[N,X] = hist(x,100); %From what I've read, hist should be histogram now. My data set includes 1 to 5, and some NaN values that I don't want to include.
hfig = figure;
bar(X,N)
hold on;
y = [0 1.2*max(N)];
참고 항목
카테고리
Help Center 및 File Exchange에서 Discrete Data Plots에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!