NCL Home > Documentation > Functions > Statistics, Extreme values

extval_mlegam

Estimates the location, shape, scale and other parameters for the Gamma distribution using maximum-likelihood estimation (MLE).

Available in version 6.4.0 and later.

Prototype

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/extval.ncl"

	function extval_mlegam (
		x        : numeric,  
		dims [*] : integer,  
		opt  [1] : logical   
	)

	return_val  :  float or double

Arguments

x

A variable of numeric type and any dimensionality. Most commonly, x(N), x(N,J) or x(N,J,I)

dims

The dimension(s) of x on which to calculate the MLE of shape, scale and location. Must be consecutive and monotonically increasing. Usually, dims=0 (corresponding to 'N').

opt

Not used. Set to False.

Return value

The output will be double if x is double and float otherwise.

The output dimensions will be based on x's dimensions, with the 'N' dimensions removed and a leftmost dimension of size 5 added:

  • If x(N) the output will be out(5)
  • If x(N,J) the output will be (5,J)
  • If x(N,J,I) the output will be out(5,J,I)
  • If x(K,N,J,I) the output will be out(5,K,J,I)

Description

Given a series, extval_mlegam calculates the maximum-likelihood estimates (MLEs) of the parameters of the Gamma distribution. The parameters are: (i) center (location), (ii) scale, (iii) shape, (iv) variance and (v) gamma quantile (median).

REFERENCE(S):

   Thom, H. C. S. (1958): A Note on the Gamma Distribution, Monthly Weather Review 
VOl. 86, No.  4, Apr.  1958, PP.  117-132. 

   Wilks: Statistical Methods in the Atmospheric Sciences (2006); pp 95-102

See Also

Extreme Value functions

Examples

Example 1:

 
   x = (/112,118,132,129,121,135,148,148,136,119,104,118 \
        ,115,126,141,135,125,149,170,170,158,133,114,140 \
        ,145,150,178,163,172,178,199,199,184,162,146,166 \
        ,171,180,193,181,183,218,230,242,209,191,172,194 \
        ,196,196,236,235,229,243,264,272,237,211,180,201 \
        ,204,188,235,227,234,264,302,293,259,229,203,229 \
        ,242,233,267,269,270,315,364,347,312,274,237,278 \
        ,284,277,317,313,318,374,413,405,355,306,271,306 \
        ,315,301,356,348,355,422,465,467,404,347,305,336 \
        ,340,318,362,348,363,435,491,505,404,359,310,337 \
        ,360,342,406,396,420,472,548,559,463,407,362,405 \
        ,417,391,419,461,472,535,622,606,508,461,390,432 /)

   gam_mle  = extval_mlegam (x, 0, False)    ; dims=0
   print(gam_mle)                            ; gam_mle(5)

The edited output is:

   Variable: gam_mle
   Type: float
   Total Size: 20 bytes
               5 values
   Number of Dimensions: 1
   Dimensions and sizes:	[5]
   Coordinates: 
   Number Of Attributes: 3
     _FillValue :	-2.147484e+09
     long_name :	gamma: maximim liklihood eatimates: location, shape, scale, gam_var, gam_quant
     NCL_tag :	extval_mlegam

   (0)	280.2986     center (aka, location)
   (1)	50.97184     scale
   (2)	5.499088     shape
   (3)	14287.34     variance
   (4)	272.2646     median  

Compare with the shape and scale returned by dim_gamfit_n. The shape and scale match.
 

   gam2 = dim_gamfit_n(x, False, 0)
   print(gam2)                                ; gam(3)

   (0)	5.49911      ; shape 
   (1)	50.9716      ; scale
   (2)	0  0