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
21 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace FSharp.Stats | ||
|
||
module ConfidenceInterval = | ||
|
||
open FSharp.Stats.Distributions | ||
|
||
// The deviation from the sample mean is calculated by using a t distribution. Common ciLevel = 0.95 | ||
let ciDeviation ciLevel (sample : seq<float>)= | ||
let n = float (Seq.length sample) | ||
let stDev = Seq.stDev sample | ||
let t = Continuous.getCriticalTValue (float n - 1.) (1. - ciLevel) Continuous.TwoTailed | ||
let delta = t * stDev / sqrt (float n) | ||
delta | ||
|
||
// The confidence interval is calculated by using a t distribution. Common ciLevel = 0.95 | ||
let ci ciLevel (sample : seq<float>)= | ||
let mean = Seq.mean sample | ||
let delta = ciDeviation ciLevel sample | ||
Intervals.create (mean - delta) (mean + delta) |
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