----- Documentation for Stat\cov2cor.pro ----- NAME: COV2COR PURPOSE: CONVERT COVARIANCE MATRIX TO MATRIX OF CORRELATION COEFFICIENTS CATEGORY: statistics CALLING SEQUENCE: COV2COR, COV, SIGMA, COR INPUTS: COV = COVARIANCE MATRIX OUTPUTS: SIGMA = ERROR ARRAY COR = CORRELATION MATRIX COMMON BLOCKS: NONE SIDE EFFECTS: NONE REQUIREMENTS: COR MUST BE SQUARE, SYMMETRIC, WITH POSITIVE DIAGONALS PROCEDURE: COV = COR / (SIGMA # SIGMA) WITH: SIGMA = SQRT(DIAG(COV)) LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2010/02/01 from www.boulder.swri.edu/~layoung/idl/layoung_v5/math/cov2cor.pro ----- Documentation for Stat\get_outlier_fences.pro ----- NAME: GET_OUTLIER_FENCES AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: return lower and upper fences identifying extreme values in tails of univariate distribution (outliers). Estimation of percentiles following NIST-recommended method http://www.itl.nist.gov/div898/handbook/prc/section2/prc252.htm For small nber of data, estimate percentiles using normal CDF CATEGORY: statistics CALLING SEQUENCE: FENCES=GET_OUTLIER_FENCES(X,ALFA,COEFF) INPUTS: X = experimental data distribution. ALFA = percentage of experimental data included in the interpercentile range. (must be gt 0 and lt 1, e.g. =0.5 for quartile-based outliers). COEFF = outlier coefficient defining types of outliers (=1.5 for mild outliers, =3 for extreme outliers). OUTPUTS: Function result = FENCES = 2-element array of outlier fences (FENCES(0)=lower fence, FENCES(1)=upper fence). OPTIONAL OUTPUT PARAMETERS: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE. LOCAL FUNCTION USED: NONE. LOCAL SYSTEM VARIABLE USED: NB_DATA_BOOT REVISION HISTORY: Written by pcr 2009/02/02 Last modification by pcr 2010/12/12 ----- Documentation for Stat\loca_scale_chi2.pro ----- NAME: LOCA_SCALE_CHI2 AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: return location and scale parameters of standard chi-square distribution for experimental data, using median (for location) and interpercentile range (for scale). interquartile range (ALFA=0.75) usually used as robust measure of scale Estimation of percentiles following NIST-recommended method http://www.itl.nist.gov/div898/handbook/prc/section2/prc252.htm CATEGORY: statistics CALLING SEQUENCE: LOCA_SCALE_CHI2,X,ALFA,NU,LOC,SCA INPUTS: X = experimental data set. ALFA = percentage of experimental data included in the interpercentile range (must be gt 0 and lt 1). NU = number of degrees of freedom. OUTPUTS: LOC = location parameter of standard chi-square distribution. SCA = scale parameter of standard chi-square distribution. OPTIONAL OUTPUT PARAMETERS: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2008/01/24 last modification by pcr 2009/09/31 ----- Documentation for Stat\loca_scale_norm.pro ----- NAME: LOCA_SCALE_NORM AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: return location and scale parameters of standard normal distribution for experimental data, using median (for location) and interpercentile range (for scale). Estimation of percentiles following NIST-recommended method http://www.itl.nist.gov/div898/handbook/prc/section2/prc252.htm CATEGORY: statistics CALLING SEQUENCE: LOCA_SCALE_NORM,X,ALFA,LOC,SCA INPUTS: X = experimental data set. ALFA = percentage of experimental data included in the interpercentile range (must be gt 0 and lt 1). OUTPUT: LOC = location parameter of standard normal distribution. SCA = scale parameter of standard normal distribution. OPTIONAL OUTPUT PARAMETERS: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2008/05/31 last modification by pcr 2009/04/14 ----- Documentation for Stat\mem_stdev.pro ----- NAME: MEM_STDEV AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: compute standard deviation of asymmetric distribution from maximum entropy principle. CATEGORY: statistics CALLING SEQUENCE: MEMSTD = MEM_STDEV(LOWER_ERROR,UPPER_ERROR) INPUTS: LOWER_ERROR = lower error. UPPER_ERROR = upper error. OPTIONAL INPUT PARAMETER: none. OUTPUTS: Function result = MEMSTD = standard deviation of distribution. OPTIONAL OUTPUT PARAMETER: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: memvar=MEMSTD^2=UPPER_ERROR*LOWER_ERROR-(UPPER_ERROR-LOWER_ERROR)/lambda where lambda is computed according to JCGM 100:2008, section 4.3.8, note 2 LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2009/10/05 Last modification by pcr 2010/12/07 ----- Documentation for Stat\plot_distri.pro ----- NAME: PLOT_DISTRI AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: plot chi-square and parameter statistics, used with fit_model and fit_sed CATEGORY: statistics CALLING SEQUENCE: PLOT_DISTRI,DELTACHI2,NU,PARA,FTIT,OUTPUT_FILE_STEM,WSKIP,CLEVEL INPUTS: DELTACHI2 = row vector of reduced chi-square differences. NU = number of degrees of freedom. FTIT = row vector of string chains for plot of free parameter axis titles. PARA = 2-dim array of free model parameters, sorted in ascending order of chi-square diff, length=length(DELTACHI2)*length(FTIT). OUTPUT_FILE_STEM = output file stem for writing in postscript files. WSKIP = index of first newly created window in current procedure. CLEVEL = confidence level. OUTPUT: WSKIP = index of next newly created window after current procedure. OPTIONAL OUTPUT PARAMETERS: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: uniform order statistic medians (quantiles) given by http://www.itl.nist.gov/div898/handbook/eda/section3/probplot.htm standardization of mean-squares from Wilson & Hilferty, Proc. of Nat. Acad. of Sciences of USA, 17, 684-688 (1931) LOCAL PROCEDURE CALLED: LOCA_SCALE_CHI2 RESET_PLOT LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: OBS_PATH PLOT_DEV REVISION HISTORY: Written by pcr 2008/04/08 last modification by pcr 2011/01/14 ----- Documentation for Stat\rect_stdev.pro ----- NAME: RECT_STDEV AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: compute standard deviation of rectangular (uniform) distribution. CATEGORY: statistics CALLING SEQUENCE: RECSTD = RECT_STDEV(LOWER_ERROR,UPPER_ERROR,CONFID_LEVEL,LOWER_BOUND,UPPER_BOUND) INPUTS: LOWER_ERROR = lower error. UPPER_ERROR = upper error. CONFID_LEVEL = level of confidence. OPTIONAL INPUT PARAMETER: none. OUTPUTS: Function result = RECSTD = standard deviation of distribution. OPTIONAL OUTPUT PARAMETER: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: recvar=RECSTD^2=cover^2*(UPPER_ERROR+LOWER_ERROR)^2/12 where cover=sqrt(2)/3*inv_erf(CONFID_LEVEL) LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2009/10/15 ----- Documentation for Stat\tri_stdev.pro ----- NAME: TRI_STDEV AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: compute standard deviation and upper/lower bounds of triangular distribution from quantiles. CATEGORY: statistics CALLING SEQUENCE: TRISTD = TRI_STDEV(MODE_VAL,LOWER_QUANT,UPPER_QUANT,LOWER_PROB, UPPER_PROB,UPPER_BOUND,LOWER_BOUND) INPUTS: MODE_VAL = mode value. LOWER_QUANT = lower quantile. UPPER_QUANT = upper quantile. LOWER_PROB = probability of lower quantile. UPPER_QUANT = probability of upper quantile. OPTIONAL INPUT PARAMETER: none. OUTPUTS: Function result = TRISTD = standard deviation of triangular distribution. UPPER_BOUND = upper limit of triangular distribution LOWER_BOUND = lower limit OPTIONAL OUTPUT PARAMETER: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: trivar=TRISTD^2=(LOWER_BOUND^2+MODE_VAL^2+UPPER_BOUND^2 -LOWER_BOUND*MODE_VAL-UPPER_BOUND*MODE_VAL -LOWER_BOUND*UPPER_BOUND)/18 where LOWER_BOUND and UPPER_BOUND are triangular distribution limits calculated from upper and lower quantiles according to Kotz & Van Dorp (2004) section 1.6 LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: EPSILON REVISION HISTORY: Written by pcr 2009/10/05 last modification by pcr 2010/12/07 ----- Documentation for Stat\wavg.pro ----- NAME: WAVG AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: compute weighted mean of data vector. CATEGORY: statistics CALLING SEQUENCE: WMEAN = WAVG(WEIGHT,DATA) INPUTS: WEIGHT = row vector of weights . DATA = row vector of data (same length as WEIGHT). OUTPUTS: Function result = WMEAN = weighted mean. OPTIONAL OUTPUT PARAMETER: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2008/05/27 last modification by pcr 2010/11/10 ----- Documentation for Stat\wstdev.pro ----- NAME: WSTDEV AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: compute weighted mean of data vector and weighted standard deviation (or mean standard weighted error). CATEGORY: statistics CALLING SEQUENCE: WSTD = WSTDEV(WEIGHT,DATA,WMEAN,ERROR) INPUTS: WEIGHT = row vector of weights . DATA = row vector of data (same length as WEIGHT). OPTIONAL INPUT PARAMETER: ERROR = row vector of errors (same length as WEIGHT). OUTPUTS: Function result = WSTD = unbiased estimator of weighted standard deviation (or mean weighted error). WMEAN = weighted mean. OPTIONAL OUTPUT PARAMETER: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: WMEAN=SUM(WEIGHT*DATA)/SUM(WEIGHT) following http://pygsl.sourceforge.net/reference/pygsl/node52.html and http://www.gnu.org/software/gsl/manual/html_node/Weighted-Samples.html : WSTDEV^2=SUM(WEIGHT)/((SUM(WEIGHT))^2-SUM(WEIGHT^2)) *SUM(WEIGHT*(DATA-WMEAN)^2) if ERROR vector provided : WSTDEV^2=SUM(WEIGHT^2*ERROR^2)/(SUM(WEIGHT))^2 LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE REVISION HISTORY: Written by pcr 2008/05/27 last modification by pcr 2010/11/13 ----- Documentation for Stat\wsterr.pro ----- NAME: WSTERR AUTHOR: pierre.cruzalebes@oca.eu PURPOSE: compute weighted mean of data vector and standard error on weighted mean CATEGORY: statistics CALLING SEQUENCE: WSTE = WSTERR(WEIGHT,DATA,WMEAN) INPUTS: WEIGHT = row vector of weights . DATA = row vector of data (same length as WEIGHT). OPTIONAL INPUT PARAMETER: NONE. OUTPUTS: Function result = WSTE = unbiased estimator of standard error on weighted mean. WMEAN = weighted mean. OPTIONAL OUTPUT PARAMETER: NONE. COMMON BLOCKS: NONE. SIDE EFFECTS: NONE. RESTRICTIONS: NONE. PROCEDURE: WMEAN=SUM(WEIGHT*DATA)/SUM(WEIGHT) following Gatz & Smith, Atmosph. Env. 29, 11, pp. 1185-1193 (1995) : WSTERR^2 = (N/N-1)/(SUM(WEIGHT))^2 * ( TOTAL((WEIGHT*DATA-AVG(WEIGHT)*WMEAN)^2) - 2.*WMEAN*TOTAL((WEIGHT-AVG(WEIGHT)) * (WEIGHT*DATA-AVG(WEIGHT)*WMEAN)) + WMEAN^2*TOTAL((WEIGHT-AVG(WEIGHT))^2) ) LOCAL PROCEDURE CALLED: NONE LOCAL FUNCTION USED: NONE LOCAL SYSTEM VARIABLE USED: NONE MODIFICATION HISTORY: Written by pcr 2010/11/13