Login    Register

XLeratorDB/statistics Documentation

KURT


KURT

Updated: 30 September 2010


Use the aggregate function KURT to calculate the kurtosis of a dataset. Kurtosis measures the peakedness of a distribution. Kurtosis is computed by taking the fourth moment of a distribution. A high kurtosis has a sharper peak and fatter tails, while a low kurtosis has a more rounded peak and shorter thinner tails. The equation for kurtosis is:

KURT function for SQL Server
 
Syntax
SELECT [wctStatistics].[wct].[KURT] (
   <@Kown_x, float,>
 
The syntax has changed as of release 1.07 and the function has changed from a scalar to an aggregate. Please make the appropriate changes when you upgrade to 1.07.
Arguments
@Known_x
the x-values to be used in the KURT calculation. @Known_x is an expression of type float or of a type that can be implicitly converted to float.
Return Types
float
Remarks
·         If there are fewer than four data points or if the standard deviation of the sample equals zero, KURT returns a NULL.
·         KURT is an AGGREGATE function and follows the same conventions as all other AGGREGATE functions in SQL Server.
·         KURT is a one-pass solution. For a two-pass solution, use the KURT_q function.
 
Examples
In this example, we calculate the KURT for a single set of x-values
SELECT wct.KURT(x) AS KURT
FROM (
      SELECT 6.1 UNION ALL
      SELECT -4.2 UNION ALL
      SELECT -10 UNION ALL
      SELECT 9.6 UNION ALL
      SELECT 9.6 UNION ALL
      SELECT 4.3 UNION ALL
      SELECT 2.3 UNION ALL
      SELECT 7.8 UNION ALL
      SELECT -7.8 UNION ALL
      SELECT 7.2
      ) n(x)
 
This produces the following result
                  KURT
----------------------
    -0.873841788610509
 
(1 row(s) affected)
In this example, we will populate some temporary table with some information about male height at some selected colleges and then calculate the KURT value. First, create the table and put some data in it:
CREATE TABLE #c(
      College     nvarchar(50),
      Mark        bigint,
      Freq        bigint
      )
     
INSERT INTO #c VALUES ('Faber College',61,5)
INSERT INTO #c VALUES ('Faber College',64,18)
INSERT INTO #c VALUES ('Faber College',67,42)
INSERT INTO #c VALUES ('Faber College',70,27)
INSERT INTO #c VALUES ('Faber College',73,7)
INSERT INTO #c VALUES ('Faber College',76,1)
INSERT INTO #c VALUES ('Faber College',79,0)
INSERT INTO #c VALUES ('Harrison University',61,4)
INSERT INTO #c VALUES ('Harrison University',64,23)
INSERT INTO #c VALUES ('Harrison University',67,36)
INSERT INTO #c VALUES ('Harrison University',70,27)
INSERT INTO #c VALUES ('Harrison University',73,8)
INSERT INTO #c VALUES ('Harrison University',76,1)
INSERT INTO #c VALUES ('Harrison University',79,1)
INSERT INTO #c VALUES ('Adams College',61,4)
INSERT INTO #c VALUES ('Adams College',64,24)
INSERT INTO #c VALUES ('Adams College',67,42)
INSERT INTO #c VALUES ('Adams College',70,17)
INSERT INTO #c VALUES ('Adams College',73,11)
INSERT INTO #c VALUES ('Adams College',76,2)
INSERT INTO #c VALUES ('Adams College',79,0)
INSERT INTO #c VALUES ('Western University',61,7)
INSERT INTO #c VALUES ('Western University',64,11)
INSERT INTO #c VALUES ('Western University',67,51)
INSERT INTO #c VALUES ('Western University',70,29)
INSERT INTO #c VALUES ('Western University',73,1)
INSERT INTO #c VALUES ('Western University',76,0)
INSERT INTO #c VALUES ('Western University',79,1)
INSERT INTO #c VALUES ('Jordan College',61,11)
INSERT INTO #c VALUES ('Jordan College',64,22)
INSERT INTO #c VALUES ('Jordan College',67,46)
INSERT INTO #c VALUES ('Jordan College',70,18)
INSERT INTO #c VALUES ('Jordan College',73,3)
INSERT INTO #c VALUES ('Jordan College',76,0)
INSERT INTO #c VALUES ('Jordan College',79,0)
Now, calculate the KURT value of the height distribution
SELECT wct.KURT(Freq) as KURT
FROM #c    
This returns the following result
                  KURT
----------------------
    -0.109665119232317
 
(1 row(s) affected)
If we wanted to calculate the KURT by college, we would enter the following statement.
SELECT College
,wct.KURT(Freq) as KURT
FROM #c    
GROUP BY college
This returns the following result
College                                                              KURT
-------------------------------------------------- ----------------------
Adams College                                           0.898726005164902
Faber College                                          0.0858977840344171
Harrison University                                     -1.60545757238505
Jordan College                                           1.69000204265626
Western University                                       1.53200638328263
 
(5 row(s) affected)
If we only wanted to return results not between -1 and 1, then we could enter the following statement.
SELECT College
,wct.KURT(Freq) as KURT
FROM #c    
GROUP BY college
HAVING ABS(wct.KURT(Freq)) > 1
This returns the following result
College                                                              KURT
-------------------------------------------------- ----------------------
Harrison University                                     -1.60545757238505
Jordan College                                           1.69000204265626
Western University                                       1.53200638328263
 
(3 row(s) affected)


  Comments
Add Comment
No Comments Yet


 |  View Topic History  |
Copyright 2010 WestClinTech LLC         Privacy Policy        Terms of Service