필터 지우기
필터 지우기

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):

답변 (1개)

Joseph Cheng
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
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
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)];

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by