Maximum Likelihood Estimation

Given n points that are assumed to be samples of a lognormal distribution, we wish to estimate the parameters of the distribution via maximizing the likelihood of our sample, and then we wish to test whether the data is plausibly drawn from this best-fitting distribution.

  x = read(dfile)
  n = nrows(x)
  fct ll(y,z) = sum(i,1,n,log(lnormd(x[i],y,z)))
  y = 0; z = 1;
  constraints q = {y > -5, y < 10, z > .5}
  maximize(ll,y,z,q)

  The function value is: -3.385912e+02
  Argument(s): (5.011714e+00 1.978510e+00 )
  Gradient: (-6.153095e-08 1.545697e-07 )
  ecode = 0, Converged.
  # of function evaluations: 33
  # of gradient evaluations: 40
  # of Quasi-Newton iterations: 18
  There are no active constraints.
      = -338.591243 

  fct lf(x) = lnormf(x,y,z)
  draw stepgraph(cdf(x))
  draw points(lf,0:maxv(x)!160)
  view
[Picture]
  ks1t(x,lf) /* test if x is data from lf */

  [K-S-test: are the samples in M plausibly drawn from the
  distribution F?]
  null hypothesis H0: M is drawn from the distribution F.
  The scaled maximum deviation between cdf(M) and F is
  distributed as the Kolmogorov-Smirnov K statistic.
  The K-statistic value = 0.494806 at the point 135.087720

  The probability P(K > 0.494806) = 0.967170
  This means that a value of K larger than 0.494806 arises
  about 96.717001 percent of the time, given H0.

      : a  5 by 1 matrix

    1: .494806371
    2: .494806371
    3: .489304956
    4: .967170007
    5: 135.08772 

[Back to CSI Home Page]
Send comments to: webmaster@civilized.com