1;$Id: skewness.pro,v 1.3 2012-07-13 22:28:02 alaingdl Exp $ 2; 3function skewness, x, double=double, NaN=NaN, dimension=dimension 4; 5;+ 6; 7; NAME: SKEWNESS 8; 9; PURPOSE: 10; Calculates the skewness of the input data 11; 12; CATEGORY: 13; Mathematics: Statistics 14; 15; CALLING SEQUENCE: Result=SKEWNESS(x [, /nan][,/double][, dim=]) 16; 17; KEYWORD PARAMETERS: 18; DOUBLE : Keyword for double precision calculation 19; NAN : Flag to treat IEEE Special Floating-Point values as missing data 20; DIMENSION : if absent or equal to zero, compute the variance over the 21; whole data. otherwise, compute along the related dimension. 22; 23; OUTPUTS: 24; Result is the mean of input data 25; 26; 27; RESTRICTIONS: 28; The input x needs to be an array of numbers (i.e not strings, 29; struct, ptr, object) 30; 31; PROCEDURE: 32; skewness = 1/N sum((x-mean(x))^3/sqrt(variance(x))), 33; Uses the MOMENT function 34; 35; EXAMPLE: 36; a=FINDGEN(100) 37; result=SKEWNESS(a) 38; print, result 39; 0.0000 40; 41; MODIFICATION HISTORY: 42; 20-Mar-2004 : Written by Christopher Lee 43; 18-Jul-2005 : PC, moment.pro update 44; 13-Jul-2012 : Alain Coulais : adding DIMENSION keyword, using MOMENT() 45; 46; LICENCE: 47; Copyright (C) 2004, Christopher Lee, 2005 P. Chanial, 2012 Alain Coulais 48; 49; This program is free software; you can redistribute it and/or modify 50; it under the terms of the GNU General Public License as published by 51; the Free Software Foundation; either version 2 of the License, or 52; (at your option) any later version. 53; 54; 55;- 56; 57 58compile_opt hidden, idl2 59 60ON_ERROR, 2 61; 62tmp = MOMENT(x, skewness=skewness, double=double, NaN=NaN, $ 63 dimension=dimension, maxmoment=3) 64; 65return, skewness 66; 67end 68