how to plot exponential pdf over a distributed data ?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
in order to find the best fit model
I want to produce this figure (a data & best fit over it):

so I try:
v=1:25;
n=[10;7;6;21;14;18;23;33;28;31;34;30;32;48;43;46;39;47;40;45;51;47;45;45;23];
plot(v,n,'*b')
ex=expfit(n);
E=exppdf(n,ex);
hold on
plot(v,E,'-r')
but it produce this figure:

how to modify the code to get the first figure?
댓글 수: 1
why there aren't any interaction?
채택된 답변
Star Strider
2015년 10월 24일
Fourteen hours ago I was asleep here in GMT-7 land.
I believe you are mistaking the exponential distribution for the exponential function.
This produces a good fit to your data:
v=1:25;
n=[10;7;6;21;14;18;23;33;28;31;34;30;32;48;43;46;39;47;40;45;51;47;45;45;23];
plot(v,n,'bp')
expfcn = @(b,x) b(1) + b(2).*exp(b(3).*x); % Three-Parameter Exponential Function
B0 = [50; -50; -0.5]; % Initial Parameter Estimates
B = nlinfit(v(:), n(:), expfcn, B0); % Estimate Parameters
E = expfcn(B,v); % Simulate Function
hold on
plot(v,E,'-r')
I used the nlinfit function because I know you have the Statistics Toolbox.
댓글 수: 6
Thanks
but I want to plot the " exponential distribution "
as I want to create the best curve fitting
so i want to try:
exponential distribution
poisson distribution
weibull distribution
that is explain why I use "exppdf"
waiting for your advices
You can fit it to whatever distribution you want (and are appropriate to your data). You simply cannot plot it as the plot you posted. All probablilty distributions to the best of my knowledge have a maximum amplitude of 1. What was plotted in the figure is an exponential function, not an exponential distribution.
The plot of the exponential distribution of your data are:
v=1:25;
n=[10;7;6;21;14;18;23;33;28;31;34;30;32;48;43;46;39;47;40;45;51;47;45;45;23];
ex=expfit(n);
E=exppdf(v,ex);
hold on
plot(E,'-r')
Amr Hashem
2015년 10월 25일
편집: Amr Hashem
2015년 10월 25일
Thanks , for your advice
that's work:
v=1:25;
n=[10;7;6;21;14;18;23;33;28;31;34;30;32;48;43;46;39;47;40;45;51;47;45;45;23];
plot(v,n,'bp')
expfcn = @(b,x) b(2).*exp(b(3).*x); % Three-Parameter Exponential Function
B0 = [50; 50; 0.5]; % Initial Parameter Estimates
B = nlinfit(v(:), n(:), expfcn, B0); % Estimate Parameters
E = expfcn(B,v); % Simulate Function
hold on
plot(v,E,'-r')
Now I have a question how to prolong the fitted curve to reach the x-axis?
My pleasure.
That requires an fzero call to find it, and to create an appropriate vector for ‘v’ that includes it.
The code changes slightly:
v=1:25;
n=[10;7;6;21;14;18;23;33;28;31;34;30;32;48;43;46;39;47;40;45;51;47;45;45;23];
plot(v,n,'*b')
expfcn = @(b,x) b(1) + b(2).*exp(b(3).*x); % Three-Parameter Exponential Function
B0 = [50; -50; -0.5]; % Initial Parameter Estimates
B = nlinfit(v(:), n(:), expfcn, B0); % Estimate Parameters
Y0 = fzero(@(x)expfcn(B,x), 1); % Find ‘v’ At E=0
vrng = linspace(Y0, max(v)); % Create Matching Vector
E = expfcn(B,vrng); % Simulate Function With ‘vrng’
hold on
plot(vrng,E,'-r')
fprintf(1, '\n\tE(%.3f) = 0\n', Y0)
The x-intercept is about 0.432.
Amr Hashem
2015년 10월 26일
편집: Amr Hashem
2015년 10월 26일
but when I try it on:
expfcn = @(b,x) b(2).*exp(b(3).*x);
x intercept at -7413 and the place of fitted curve changed I use
expfcn = @(b,x) b(2).*exp(b(3).*x);
as this the function of exponential i want
so I adjust the code to :
v=1:25;
n=[10;7;6;21;14;18;23;33;28;31;34;30;32;48;43;46;39;47;40;45;51;47;45;45;23];
plot(v,n,'*b')
expfcn = @(b,x) ( b(2).*exp(b(3).*x)); % Three-Parameter Exponential Function
B0 = [50; -50; -0.5]; % Initial Parameter Estimates
B = nlinfit(v(:), n(:), expfcn, B0); % Estimate Parameters
vrng = linspace(-35, max(v)); % Create Matching Vector
E = expfcn(B,vrng); % Simulate Function With ‘vrng’
hold on
plot(vrng,E,'-r')
this is work, but I didn't know how to find the intercept I write it manually ?
The x-intercept, such as it is, fzero calculates as -20970.520.
You could probably find the intercept manually, but your code is incorrect when estimating the parameters.
My code here is the correct method:
v=1:25;
n=[10;7;6;21;14;18;23;33;28;31;34;30;32;48;43;46;39;47;40;45;51;47;45;45;23];
plot(v,n,'*b')
expfcn = @(b,x) b(1).*exp(b(2).*x); % Two-Parameter Exponential Function
B0 = [50; 0]; % Initial Parameter Estimates
B = nlinfit(v(:), n(:), expfcn, B0); % Estimate Parameters
Y0 = fzero(@(x)expfcn(B,x), 1); % Find ‘v’ At E=0
vrng = linspace(Y0, max(v)); % Create Matching Vector
E = expfcn(B,vrng); % Simulate Function
hold on
plot(vrng,E,'-r')
fprintf(1, '\n\tE(%.3f) = 0\n', Y0)
You are only fitting two parameters, so you can only specify two in the nlinfit argument list, and you have to refer to them correctly in the ‘expfcn’ objective function. Otherwise, nlinfit will attempt to fit all three of them, even though your function is using only two, and will likely return inaccurate results for the two it does estimate.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Exponential Distribution에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
