MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Fitting NormalDistribution to 2D List

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31520] Re: [mg31459] Re: Fitting NormalDistribution to 2D List
  • From: BobHanlon at aol.com
  • Date: Thu, 8 Nov 2001 04:57:14 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 2001/11/7 8:25:33 AM, post_12 at hotmail.com writes:

>While the code you posted solves the specific example I asked about, I
>am still unable to fit my data to an arbitrary distribution (e.g.
>ExtremeValue, LaPlace). Is there a way to pass these distributions and
>my Tables of data to the Nonlinear fitting algorithm? Unrolling is
>unfortunately not an option; my machine (1GB RAM) ran out of memory
>trying to unroll 1 data set.
>

Needs["Statistics`ContinuousDistributions`"];
Needs["Statistics`DataManipulation`"];

binnedMean[data_]:=Tr[Times@@#&/@data]/Tr[data[[All,2]]];

dist = ExtremeValueDistribution[alpha, beta];

Generate random data

data = RandomArray[ExtremeValueDistribution[5,2],{10000}];

Bin the data

xmin = Min[data];
xmax = Max[data];
nbrBins = 20;

binnedData = 
    Select[({Mean[#], Length[#]}& /@ 
          BinLists[data, {xmin, xmax, (xmax-xmin)/nbrBins}]), #[[2]] > 0&];

Use binnedData statistics to estimate the parameters

m = binnedMean[binnedData];

{alphaEst, betaEst} = {alpha, beta} /. Solve[{Mean[dist] == m, 
          StandardDeviation[dist] == 
            Sqrt[binnedMean[{(#[[1]]-m)^2,#[[2]]}&/@binnedData]]}, {alpha, 
          beta}][[1]]

{5.024306536076431, 
  1.973745897321664}

Develop maximum likelihood estimates

logPDF[x_] := 
    Evaluate[PowerExpand[Log[PDF[dist, x]]]];

logPDFprod = Simplify[Tr[#[[2]]*logPDF[#[[1]]]& /@ binnedData]];

eqns = {D[logPDFprod, alpha] == 0, D[logPDFprod, beta] == 0};

FindRoot[eqns, {alpha, alphaEst}, {beta, betaEst}]

{alpha -> 5.022912945470625, 
  beta -> 1.976571171905959}


Bob Hanlon
Chantilly, VA  USA


  • Prev by Date: Re: 2nd order differential equation help
  • Next by Date: Re: 2nd order differential equation help
  • Previous by thread: Re: Re: Fitting NormalDistribution to 2D List
  • Next by thread: Re: Second-degree polynomial