Updated: 6 August 2010
Use FTEST to return the result of an F-test. An F-test returns the two-tailed probability that variance in dataset 1 and dataset 2 are not significantly different. Use this function to determine whether two samples have different variances.
Syntax
SELECT [wctStatistics].[wct].[FTEST] (
<@Values1_TableName, nvarchar(4000),>
,<@Values1_ColumnName, nvarchar(4000),>
,<@Values1_GroupedColumnName, nvarchar(4000),>
,<@Values1_GroupedColumnValue, sql_variant,>
,<@Values2_TableName, nvarchar(4000),>
,<@Values2_ColumnName, nvarchar(4000),>
,<@Values2_GroupedColumnName, nvarchar(4000),>
,<@Values2_GroupedColumnValue, sql_variant,>)
Arguments
@Values1_TableName
the name, as text, of the table or view that contains the values in the first dataset to be used in the FTEST calculation.
@Values1 _ColumnName
the name, as text, of the column in the table or view specified by @Values1_TableName that contains the values in the first dataset to be used in the FTEST calculation.
@Values1 _GroupedColumnName
the name, as text, of the column in the table or view specified by @Values1_TableName which will be used for grouping the results of the first dataset.
@Values1 _GroupedColumnValue
the column value to do the grouping on for the first dataset.
@Values2_TableName
the name, as text, of the table or view that contains the values in the second dataset to be used in the FTEST calculation.
@Values2 _ColumnName
the name, as text, of the column in the table or view specified by @Values2_TableName that contains the values in the second dataset to be used in the FTEST calculation.
@Values2 _GroupedColumnName
the name, as text, of the column in the table or view specified by @Values2_TableName which will be used for grouping the results of the second dataset.
@Values2 _GroupedColumnValue
the column value to do the grouping on for the second dataset.
Return Types
float
Remarks
· If the number of rows in dataset 1 or dataset 2 is less than 2, FTEST will return an error
· If the variance of dataset 1 or the variance of dataset 2 is zero, FTEST will return a divide by zero error.
· For more complex queries consider using FTEST_q
· No GROUP BY is required for this function even though it produces aggregated results.
Examples
CREATE TABLE #data1(
[num] [float] NOT NULL
)
INSERT INTO #data1 VALUES (6)
INSERT INTO #data1 VALUES (7)
INSERT INTO #data1 VALUES (9)
INSERT INTO #data1 VALUES (15)
INSERT INTO #data1 VALUES (21)
CREATE TABLE #data2(
[num] [float] NOT NULL
)
INSERT INTO #data2 VALUES (20)
INSERT INTO #data2 VALUES (28)
INSERT INTO #data2 VALUES (31)
INSERT INTO #data2 VALUES (38)
INSERT INTO #data2 VALUES (40)
Select wct.FTEST('#data1','num','',NULL,'#data2','num','',NULL)
This produces the following result
----------------------
0.648317846786174
(1 row(s) affected)