-
Notifications
You must be signed in to change notification settings - Fork 1
/
NBSSpec.hs
58 lines (46 loc) · 1.86 KB
/
NBSSpec.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
-- | A test suite based on section 12.3 of W.J. Riley's
-- /Handbook of Frequency Stability Analysis/.
module TauSigma.Statistics.NBSSpec where
import Data.Tagged
import Data.Vector (Vector)
import qualified Data.Vector as V
import TauSigma.Types
import TauSigma.Statistics.Util (integrate)
import TauSigma.Statistics.Allan (adev, mdev, tdev)
import TauSigma.Statistics.Hadamard (hdev)
import TauSigma.Statistics.Total (totdev)
import TauSigma.Statistics.ComparisonTest
import Test.Hspec
spec :: Spec
spec = do
describe "NBS Monograph 140, Annex 8.E" $ do
describe "Overlapping Allan Deviation" $ do
it "tau = 1" $ adev 1 1 `shouldBeAbout` 91.22945
it "tau = 2" $ adev 1 2 `shouldBeAbout` 85.95287
describe "Modified Allan Deviation" $ do
it "tau = 1" $ mdev 1 1 `shouldBeAbout` 91.22945
it "tau = 2" $ mdev 1 2 `shouldBeAbout` 74.78849
describe "Time Deviation" $ do
it "tau = 1" $ tdev 1 1 `shouldBeAbout` 52.67135
it "tau = 2" $ tdev 1 2 `shouldBeAbout` 86.35831
describe "Overlapping Hadamard Deviation" $ do
it "tau = 1" $ hdev 1 1 `shouldBeAbout` 70.80607
it "tau = 2" $ hdev 1 2 `shouldBeAbout` 85.61487
describe "Total Deviation" $ do
it "tau = 1" $ totdev 1 1 `shouldBeAbout` 91.22945
it "tau = 2" $ totdev 1 2 `shouldBeAbout` 93.90379
where shouldBeAbout = comparison nbsData 4.0e-6
-- | NBS Monograph 140, Annex 8.E Test Data
nbsData :: Vector Double
nbsData = integrate (V.fromList (map untag raw))
where raw :: [FreqData Double]
raw = [ 8.920000000000000e+02
, 8.090000000000000e+02
, 8.230000000000000e+02
, 7.980000000000000e+02
, 6.710000000000000e+02
, 6.440000000000000e+02
, 8.830000000000000e+02
, 9.030000000000000e+02
, 6.770000000000000e+02
]