Package: lmoments
"""This library was designed to use L-moments to predict optimal parametersfor a number of distributions.  Distributions supported in this file arelisted below, with their distribution suffix:*Exponential (EXP)*Gamma (GAM)*Generalised Extreme Value (GEV)*Generalised Logistic (GLO)*Generalised Normal (GNO)*Generalised Pareto (GPA)*Gumbel (GUM)*Kappa (KAP)*Normal (NOR)*Pearson III (PE3)*Wakeby (WAK)*Weibull (WEI)The primary function in this file is the samlmu(x,nmom) function, which takesan input dataset x and  input of the number of moments to produce the logmoments of that dataset.For Instance, given a list "Data", if 5 l-moments are needed, the functionwould be called by lmoments.samlmu(Data,5)In this file contains four different functions for using each distribution.Each function can be called by the prefix FUN with the suffix DIS.*PEL: (x,nmom):Parameter Estimates.  This takes the L-Moments calculated by samlmu()and predicts the parameter estimates for that function.EXAMPLE: Find Wakeby distribution that best fits dataset DATA:import lmomentspara = lmoments.pelwak(lmoments.samlmu(DATA,5))*QUA: (f,para)Quantile Estimates.  This takes the parameter estimates for adistribution, and a given Quantile value to calculate the quantile for thegiven function.EXAMPLE: Find the Upper Quantile (75%) of the Kappa distribution thatbest fits dataset DATA:import lmomentspara = lmoments.pelkap(lmoments.samlmu(DATA,5))UQ = lmoments.quakap(0.75,para)*LMR: (para,nmom):L-Moment Ratios.  This takes the parameter estimates for a distributionand calculates nmom L-Moment ratios.EXAMPLE: Find 4 lmoment ratios for the Gumbel distribution thatbest fits dataset DATA:import lmomentspara = lmoments.pelgum(lmoments.samlmu(DATA,5))LMR = lmoments.lmrgum(para,4)*CDF: (x,para):Cumulative Distribution Function.  This takes the parameter estimatesfor a distribution and calculates the quantile for a given value x.EXAMPLE: Find the quantile of the datapoint 6.4 for the WeibullDistribution that best fits the dataset DATA:import lmomentspara = lmoments.pelwei(lmoments.samlmu(DATA,5))quantile = lmoments.cdfwei(6.4,para)*PDF: (x,para):Probability Distribution Function.  This takes the parameter estimatesfor a distribution and calculates the p value for a given value x.EXAMPLE: Find the p-value of the datapoint 6.4 for the WeibullDistribution that best fits the dataset DATA:import lmomentspara = lmoments.pelwei(lmoments.samlmu(DATA,5))quantile = lmoments.pdfwei(6.4,para)*LMOM: (para):L-Moment Estimation from Parameters.  This function takes the inputparameters for a given distribution, and attempt to calculate theL-Moments that would correspond to this distribution.EXAMPLE: Estimate the L-Moments of the Weibull Distribution that hasparameters (2.5,1.5,0.5)import lmomentsLmoments = lmoments.lmomwei([2.5,1.5,0.5])#RAND:  (n,para)Random Number Generator for a given function.  This takes a curve fitand returns a list of random numbers generated from that distributionEXAMPLE: Generate 10 numbers from the weibull distribution that makesup the dataset "data"import lmomentsweibullfit = lmoments.pelwei(lmoments.samlmu(data))randnums = lmoments.randwei(10,weibullfit)*NlogL: (data,dist,peldist):Calculates the Negative Log Likelihood for use in AIC/AICc/BIC calculations.Provide data, and distribution to calculate NlogL.  Can also provide curvefitting parameters, but if they aren't provided, then the function willgenerate them via pelxxx(samlmu(data)).  To specify the distribution, use thethree letters typically assigned.EXAMPLE: Calculate the Negative Log Likelihood of a Gamma distributionfitted to Data.import lmomentsNLL = lmoments.NlogL(data,"GAM")EXAMPLE:  Calculate the Negative Log Likelihood of a Gamma distributionwith parameters [2.5,1.0] when fitted to Data.import lmomentsNLL = lmoments.NlogL(data,"GAM",[2.5,1.0])*AIC: (data,dist,*distfit):Calculate the Akaike Information Criterion (AIC) using the chosen datasetand distributionEXAMPLE:  Calculate the Akaike Information Criterion for the weibulldistribution using the input dataset data:import lmomentsAkaike = AIC(data,"WEI")*BIC: (data,dist,*distfit):Calculate the Bayesian Information Criterion (AIC) using the chosen datasetand distributionEXAMPLE:  Calculate the Bayesian Information Criterion for the weibulldistribution using the input dataset data:import lmomentsAkaike = AIC(data,"WEI")This file contains a Python implimentation of the lmoments.f library created byJ. R. M. HOSKING.The base Fortran code is copyright of the IBM Corperation, and the licensinginformation is shown below:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%IBM software disclaimerLMOMENTS: Fortran routines for use with the method of L-momentsPermission to use, copy, modify and distribute this software for any purposeand without fee is hereby granted, provided that this copyright and permissionnotice appear on all copies of the software. The name of the IBM Corporationmay not be used in any advertising or publicity pertaining to the use of thesoftware. IBM makes no warranty or representations about the suitability of thesoftware for any purpose. It is provided "AS IS" without any express or impliedwarranty, including the implied warranties of merchantability, fitness for aparticular purpose and non-infringement. IBM shall not be liable for any direct,indirect, _special or consequential damages resulting from the loss of use,data or projects, whether in an action of contract or tort, arising out of orin connection with the use or performance of this software.%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Additional code from the R library "lmomco" has been converted into Python.This library was developed by WILLIAM ASQUITH, and was released under the GPL-3License. Copyright (C) 2012 WILLIAM ASQUITHThe Python translation was conducted by:Sam GillespieNumerical AnalystC&R ConsultingTownsville AustraliaSeptember 2013For more information, or to report bugs, contact:sam.gillespie@my.jcu.edu.auLicensing for Python Translation:####################################################Copyright (C) 2014 Sam GillespieThis program is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program.  If not, see <http://www.gnu.org/licenses/>.Version 0.1.0:####################################################Initial ReleaseVersion 0.1.1:Corrected Small Errors and TyposVersion 0.2.0:Added Probability Density Functions (PDF)Added Reverse Lmoment Estimation Functions (LMOM)Added Negative Log Likelhood Function (NlogL)Included Unit TestsImplimented better version of PELWAK functionSupport for lists as x inputs for all CDF functionsBugfixesNow licensed under the GPLv3VERSION 0.2.1:Support for lists as F inputs for all QUA functionsAdded Random Number Generator (rand) for all functionsSplit the main lmoments.py file into several files, as theproject is getting to large to maintain as one single file.VERSION 0.2.2:Improved samlmu function to support any value of nmomAdded Bayesian Information Criterion (BIC) functionFixed import glitch that allowed users to import container filesGeneral BugfixesVERSION 0.2.3A bug was found that negative floats would be incorrectly handled in some cases."""