Skip to content

Commit

Permalink
add FTest module
Browse files Browse the repository at this point in the history
  • Loading branch information
zieglerSe committed Aug 21, 2020
1 parent f0da44c commit 0296258
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/FSharp.Stats/FSharp.Stats.fsproj
Expand Up @@ -96,6 +96,7 @@
<Compile Include="Testing\TestStatistics.fs" />
<Compile Include="Testing\Anova.fs" />
<Compile Include="Testing\TTest.fs" />
<Compile Include="Testing\FTest.fs" />
<Compile Include="Testing\ChiSquareTest.fs" />
<Compile Include="Testing\Bartlett.fs" />
<Compile Include="Testing\PostHoc.fs" />
Expand Down
24 changes: 24 additions & 0 deletions src/FSharp.Stats/Testing/FTest.fs
@@ -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

0 comments on commit 0296258

Please sign in to comment.