How to show with a line/arrow the center/one/two standard deviation of the normal distribution plot?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Joseph Cheng
am 6 Okt. 2015
Bearbeitet: Joseph Cheng
am 6 Okt. 2015
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 Kommentare
Joseph Cheng
am 6 Okt. 2015
Bearbeitet: Joseph Cheng
am 6 Okt. 2015
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
am 20 Mai 2020
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)];
Siehe auch
Kategorien
Mehr zu Discrete Data Plots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!