-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherf_test.jule
More file actions
53 lines (51 loc) · 980 Bytes
/
erf_test.jule
File metadata and controls
53 lines (51 loc) · 980 Bytes
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
// Copyright 2025 mertcandav.
// Use of this source code is governed by a BSD 3-Clause
// license that can be found in the LICENSE file.
use "std/math"
use "std/testing"
#test
fn testNormalQuantile(t: &testing::T) {
// Values from https://www.johndcook.com/blog/normal_cdf_inverse/
p := [
0.0000001,
0.00001,
0.001,
0.05,
0.15,
0.25,
0.35,
0.45,
0.55,
0.65,
0.75,
0.85,
0.95,
0.999,
0.99999,
0.9999999,
]
ans := [
-5.199337582187471,
-4.264890793922602,
-3.090232306167813,
-1.6448536269514729,
-1.0364333894937896,
-0.6744897501960817,
-0.38532046640756773,
-0.12566134685507402,
0.12566134685507402,
0.38532046640756773,
0.6744897501960817,
1.0364333894937896,
1.6448536269514729,
3.090232306167813,
4.264890793922602,
5.199337582187471,
]
for i, v in p {
got := NormalQuantile(v)
if !Tolerance(got, ans[i], 1e-10) {
t.Errorf("Quantile mismatch. Case {}, want: {}, got: {}", i, ans[i], got)
}
}
}