Re: Gamma distribution
- To: mathgroup at smc.vnet.net
- Subject: [mg41962] Re: Gamma distribution
- From: bobhanlon at aol.com (Bob Hanlon)
- Date: Wed, 11 Jun 2003 13:17:56 -0400 (EDT)
- References: <bc6n8p$2fo$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Needs["Statistics`ContinuousDistributions`"]; data=RandomArray[GammaDistribution[5, 1/5],{100}]; dist = GammaDistribution[alpha, beta]; log likelihood function: llhf = Tr[Log[PDF[dist,#]]& /@ data]; Estimate of parameters to use in numerical solution for MLE for parameters: est = Solve[{ Mean[dist]==Mean[data], Variance[dist]==VarianceMLE[data]}, {alpha,beta}][[1]] {alpha -> 4.444052928984766, beta -> 0.21579167371242627} MLE soln1= FindRoot[ Evaluate[{D[llhf,alpha]==0,D[llhf,beta]==0}],{alpha,alpha/.est},{beta, beta/.est}] {alpha -> 4.373815510994448, beta -> 0.21925698901897303} soln2= FindRoot[ Evaluate[{D[llhf,alpha]==0, D[llhf,beta]==0}],{alpha,{.975alpha,1.025alpha}/.est},{beta,{.975beta, 1.025beta}/.est}] {alpha -> 4.373815523637673, beta -> 0.21925698846795286} If neither the Newton method (soln1) nor the secant method (soln2) converge, try iterating using the results as the new starting values. Bob Hanlon In article <bc6n8p$2fo$1 at smc.vnet.net>, civnrn at hotmail.com (Rees) wrote: << Subject: Gamma distribution From: civnrn at hotmail.com (Rees) To: mathgroup at smc.vnet.net Date: Wed, 11 Jun 2003 07:55:05 +0000 (UTC) Hi, i wish to know whether it is possible to fit a gamma distribution to a dataset. I am using Mathematica v4.2.