Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
namespace FSharp.Stats.Testing | ||
|
||
module FTest = | ||
|
||
open FSharp.Stats | ||
|
||
/// F-Test to compare two variances from data | ||
let testVariancesFromData (data1:Vector<float>) (data2:Vector<float>) = | ||
if data1.Length = 0 || data2.Length = 0 then failwithf "Data cannot be empty." | ||
let var1 = Seq.var data1 | ||
let var2 = Seq.var data2 | ||
let df1 = float data1.Length - 1. | ||
let df2 = float data2.Length - 1. | ||
if var1 > var2 then | ||
let statistic = var1 / var2 | ||
Testing.TestStatistics.createFTest statistic df1 df2 | ||
else | ||
let statistic = var2 / var1 | ||
Testing.TestStatistics.createFTest statistic df2 df1 | ||
|
||
/// F-Test to compare two variances from given parameters. | ||
let testVariancesFromVarAndDof (var1:float)(var2:float)(df1:float)(df2:float) = | ||
let statistic = var1 / var2 | ||
Testing.TestStatistics.createFTest statistic df1 df2 |