Re: Re: Fitting NormalDistribution to 2D List
- To: mathgroup at smc.vnet.net
- Subject: [mg31507] Re: [mg31459] Re: Fitting NormalDistribution to 2D List
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Thu, 8 Nov 2001 04:55:27 -0500 (EST)
- References: <9s1uhd$o4b$1@smc.vnet.net> <200111071029.FAA26392@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
postman wrote:
>
> BobHanlon at aol.com wrote in message news:<9s1uhd$o4b$1 at smc.vnet.net>...
> > Needs["Statistics`NormalDistribution`"];
> > Needs["Statistics`DescriptiveStatistics`"];
>
> Bob:
>
> This was very helpful, thanks for taking the time to post. I still
> haven't got my head around the use of symbols like # and & in
> Mathematica, but I will use your examples to learn more about them
>
> 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.
>
> Thanks again for your help -
>
> >
> > data={{1,2},{2,8},{3,16},{4,7},{5,3}};
> >
> > unrolledData = Flatten[Table[#[[1]],{#[[2]]}]& /@data];
> >
> > mu = Mean[unrolledData];
> >
> > To find the mean without unrolling
> >
> > mu==(Plus@@(Times@@#& /@ data))/(Plus@@data[[All,2]])
> >
> > True
> >
> > or
> >
> > mu==Tr[Times@@#& /@ data]/Tr[data[[All,2]]]
> >
> > True
> >
> > or
> >
> > mu==(Dot@@Transpose[data])/Tr[data[[All,2]]]
> >
> > True
> >
> > Selecting a method
> >
> > binnedMean[data_] := Tr[Times@@#& /@ data]/Tr[data[[All,2]]];
> >
> > m = binnedMean[data];
> >
> > The StandardDeviationMLE of the data without "unrolling" is
> >
> > s = Sqrt[binnedMean[{(#[[1]]-m)^2, #[[2]]}& /@ data]];
> >
> > s == StandardDeviationMLE[unrolledData]
> >
> > True
> >
> > The distribution is
> >
> > NormalDistribution[m, s]
> >
> > NormalDistribution[109/36,
> > Sqrt[1259]/36]
> >
> >
> > Bob Hanlon
> > Chantilly, VA USA
Your data could be massaged in some way to make it correspond to
a CDF. This should not require unrolling (I think you just need to
normalize for population size and convert to a running tally). You
could then fit to the CDF of interest. With data appropriately converted
this step may be done as below.
extrmvalcdf = CDF[ExtremeValueDistribution[alpha, beta], x];
evfit = NonlinearFit[data, extrmvalcdf, x, {alpha, beta}]
Daniel Lichtblau
Wolfram Research
- References:
- Re: Fitting NormalDistribution to 2D List
- From: post_12@hotmail.com (postman)
- Re: Fitting NormalDistribution to 2D List