Log Normal Distribution Fitting

조회 수: 12 (최근 30일)
Daniel Chang
Daniel Chang 2011년 8월 25일
[EDIT: 20110826 15:26 CDT - merge duplicate - WDR]
Can someone please help me write an equation to fit a log normal distribution curve? I'm really bad at writing "anything" in matlab and ezyfit gives me several errors when I try. Please help if you can and thank you.
[Information from duplicate]
I'm using Matlab v.7.5.x and this version lacks many of the new and easier commands and functions for data fitting. I'm using ezyfit to make up for the lack of data fitting but ezyfit lacks the log-normal distribution fitting, if anyone can help me by posting up the equation of the log-normal fit it would be very helpful and greatly appreciated. Thank you.

답변 (5개)

Rick Rosson
Rick Rosson 2011년 8월 31일
You can find closed-form equations for the PDF and CDF on Wikipedia, and then use one or the other to estimate a curve that "fits" your data as closely as you can. You could then define an error statistic (perhaps sum of the squared deviation) that measures how "close" your estimate fits the data, and then try to minimize the error statistic through trial-and-error.
Obviously, this approach is not ideal, but without the Statistics Toolbox or Curve Fitting Toolbox, I am not sure what else to suggest.
The link to Wikipedia is: Log-Normal Distribution
Please note that base MATLAB provides all of the mathematical functions you will need for both the PDF and the CDF. These include:
  • the error function - erf
  • the exponential - exp
  • and the natural logarithm - log
HTH.
Rick

Rick Rosson
Rick Rosson 2011년 8월 25일
Do you have access to the Statistics Toolbox? If so, please try the lognfit function. For more information (including a simple example):
>> doc lognfit
HTH.
Rick

Daniel Chang
Daniel Chang 2011년 8월 26일
I don't have the statistics toolbox, this is for Matlab v. 7.5.x and most of the functions are lacking so I use ezyfit to make up for the lack of Matlab controls.

bym
bym 2011년 8월 26일
you can try this from the FEX:
  댓글 수: 1
Daniel Chang
Daniel Chang 2011년 8월 31일
I can't seem to get the fit function to work-
plot_log_normal( x,params,hAx,plot_num,fontsize )
I have problems with the hAx variable and it gives me a ylim error.

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


Euan
Euan 2012년 12월 7일
For a set of data x, the two maximum likelihood parameters for a log-normal distribution are mean(log(x))and std(log(x)). The resulting density function is: f(x) = 1/sqrt(2 pi) 1/(s x) exp(-(1/2s^2)(loge(x)-m)^2 ). See MatLab lognpdf and logncdf (but these may be in the stats toolbox).

Community Treasure Hunt

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

Start Hunting!

Translated by