FTEST_q
Updated 2023-10-26 14:04:48.443000
Syntax
SELECT [westclintech].[wct].[FTEST_q] (
<@Values1_RangeQuery, nvarchar(4000),>
,<@Values2_RangeQuery, nvarchar(4000),>)
Description
Use the scalar function FTEST_q 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.
F = \frac{\text{Explained Variance}}{\text{Unexplained variance}}
Arguments
@Values1_RangeQuery
the select statement, as text, used to determine the first set of values to be used in the FTEST_q calculation.
@Values2_RangeQuery
the select statement, as text, used to determine the second set of values to be used in the FTEST_q calculation.
Return Type
float
Remarks
If the number of rows in dataset 1 or dataset 2 is less than 2, FTEST_q will return an error.
If the variance of dataset 1 or the variance of dataset 2 is zero, FTEST_q will return a divide by zero error.
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_q('Select num from #data1', 'Select num from #data2');
This produces the following result
{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"0.648317846786174"}]}