Mean and 3-sgima for Lognormal distributions
Hello,
I am trying to plot the lognormal distribution over 10 iterations and would like to see the mean and 3 sigma outliers. Somehow, doing this for lognormal plots does not look easy. Also, is it possible that I can skip the histogram in my plots and only look at the lognormal curves? This is the code snippet I am using. Thanks!
figure(113);
for i = 1:10
norm=histfit(Current_c(i,:),10,'lognormal'); %%Current_c is a 10*100 matrix %%
[muHat, sigmaHat] = lognfit(Current_c(i,:));
% Plot bounds at +- 3 * sigma.
lowBound = muHat - 3 * sigmaHat;
highBound = muHat + 3 * sigmaHat;
yl = ylim;
%line([lowBound, lowBound], yl, 'Color', [0, .6, 0], 'LineWidth', 3);
%line([highBound, highBound], yl, 'Color', [0, .6, 0], 'LineWidth', 3);
line([muHat, muHat], yl, 'Color', [0, .6, 0], 'LineWidth', 3);
grid on;
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Line segmentation', 'NumberTitle', 'Off')
hold on;
end
NOTE:-
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
to visualize the mean, sigma and 3 sigma on the curve of the probability distribution that approximates your data you have to consider that the bins of the histogram and too wide to directly get accurate marks on the curve, let me explain:
If you try
find(y==my)
=
Empty matrix: 1-by-0
no match
But you can find the histogram bin where the mean is contained in:
find(y>my)
=
Columns 1 through 14
3 4 5 6 7 8 9 10 11 12 13 14 15 16
Columns 15 through 28
17 18 19 20 21 22 23 24 25 26 27 28 29 30
Columns 29 through 31
31 32 33find(y<=my)
=
Columns 1 through 14
1 2 34 35 36 37 38 39 40 41 42 43 44 45
Columns 15 through 28
46 47 48 49 50 51 52 53 54 55 56 57 58 59
Columns 29 through 42
60 61 62 63 64 65 66 67 68 69 70 71 72 73
Columns 43 through 56
74 75 76 77 78 79 80 81 82 83 84 85 86 87
Columns 57 through 69
88 89 90 91 92 93 94 95 96 97 98 99 100
Let be ny the reference vector of y:
ny=[1:1:length(y)]
then the mean value is somewhere within the interval
[33 34]
So, to accurately plot my and 3*sy you first have to decide how accurate you need be.
While the y step is, and it varies along the curve
abs(y(33)-y(34))
ans =
0.258998840336178
the x step is constant
abs(x(33)-x(34))
=
0.011562155305573mean(diff(x))
= 0.011562155305573max(diff(x))
= 0.011562155305573min(diff(x))
= 0.011562155305573
So if you decide that 2 decimals precision (on y) is enough, we have to refine x small enough so that at least one point of y interpolated has the value my truncated after 2nd decimal:
3.02xxxx
for 0.2589 go down to 0.0001 the y step has to be fractioned at least
0.2589/dy=0.0001 hence dy=258.9 , let’s take dy=259
the angle
SEE COMPLETE ANSWER CLICK THE LINK