Skip to content

Commit 8d021a0

Browse files
committed
Test value stability of sphere and circle sampling
1 parent 228fa14 commit 8d021a0

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/distributions/unit_circle.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,13 @@ mod tests {
8282
assert_almost_eq!(x[0]*x[0] + x[1]*x[1], 1., 1e-15);
8383
}
8484
}
85+
86+
#[test]
87+
fn value_stability() {
88+
let mut rng = ::test::rng(2);
89+
let dist = UnitCircle::new();
90+
assert_eq!(dist.sample(&mut rng), [-0.8150602311723979, 0.5793762331690843]);
91+
assert_eq!(dist.sample(&mut rng), [-0.056204569973983196, 0.998419273809375]);
92+
assert_eq!(dist.sample(&mut rng), [0.7761923749562624, -0.630496151502733]);
93+
}
8594
}

src/distributions/unit_sphere.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,16 @@ mod tests {
7777
assert_almost_eq!(x[0]*x[0] + x[1]*x[1] + x[2]*x[2], 1., 1e-15);
7878
}
7979
}
80+
81+
#[test]
82+
fn value_stability() {
83+
let mut rng = ::test::rng(2);
84+
let dist = UnitSphereSurface::new();
85+
assert_eq!(dist.sample(&mut rng),
86+
[0.1660727273690104, 0.5202698793511903, 0.8376986939610902]);
87+
assert_eq!(dist.sample(&mut rng),
88+
[0.40052443371799834, 0.4237054996596154, -0.812436968356975]);
89+
assert_eq!(dist.sample(&mut rng),
90+
[0.9209910250970449, -0.32692477745072107, 0.21188610520628948]);
91+
}
8092
}

0 commit comments

Comments
 (0)