-
Notifications
You must be signed in to change notification settings - Fork 1
/
AllanSpec.hs
77 lines (70 loc) · 2.32 KB
/
AllanSpec.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
module TauSigma.Statistics.AllanSpec where
import Pipes
import TauSigma.Statistics.Allan (adevs)
import TauSigma.Statistics.SlopeTest
import TauSigma.Util.Pipes.Noise
( whitePhase
, flickerPhase
, whiteFrequency
, flickerFrequency
, randomWalkFrequency
, toPhase
, octaves
)
import Test.Hspec
spec :: Spec
spec = describe "adev" (mapM_ slopeTest adevCases)
adevCases :: [TestCase]
adevCases =
[ TestCase { name = "wpm"
, description = "Slope of white phase noise ~ -1.0"
, samples = sampleSize
, taus = (10, 20)
, expected = (-1.0)
, tolerance = 0.1
, statistic = adevs 1
, noise = wpm
}
, TestCase { name = "fpm"
, description = "Slope of flicker phase noise ~ -1.0"
, samples = sampleSize
, taus = (10, 20)
, expected = (-1.0)
, tolerance = 0.18
, statistic = adevs 1
, noise = fpm
}
, TestCase { name = "wfm"
, description = "Slope of white frequency noise ~ -0.5"
, samples = sampleSize
, taus = (10, 20)
, expected = (-0.5)
, tolerance = 0.05
, statistic = adevs 1
, noise = wfm
}
, TestCase { name = "ffm"
, description = "Slope of flicker frequency noise ~ 0.0"
, samples = sampleSize
, taus = (10, 20)
, expected = (0.0)
, tolerance = 0.055
, statistic = adevs 1
, noise = ffm
}
, TestCase { name = "rwfm"
, description = "Slope of random walk frequency noise ~ 0.5"
, samples = sampleSize
, taus = (10, 20)
, expected = (0.5)
, tolerance = 0.05
, statistic = adevs 1
, noise = rwfm
}
]
where sampleSize = 200000
wpm = whitePhase 1.0
fpm = flickerPhase (octaves sampleSize) 1.0
wfm = whiteFrequency 1.0 >-> toPhase
ffm = flickerFrequency (octaves sampleSize) 1.0 >-> toPhase
rwfm = randomWalkFrequency 1.0 >-> toPhase