Skip to content

Commit

Permalink
Test value stability of sphere and circle sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
vks committed Jul 27, 2018
1 parent 228fa14 commit 8d021a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/distributions/unit_circle.rs
Expand Up @@ -82,4 +82,13 @@ mod tests {
assert_almost_eq!(x[0]*x[0] + x[1]*x[1], 1., 1e-15);
}
}

#[test]
fn value_stability() {
let mut rng = ::test::rng(2);
let dist = UnitCircle::new();
assert_eq!(dist.sample(&mut rng), [-0.8150602311723979, 0.5793762331690843]);
assert_eq!(dist.sample(&mut rng), [-0.056204569973983196, 0.998419273809375]);
assert_eq!(dist.sample(&mut rng), [0.7761923749562624, -0.630496151502733]);
}
}
12 changes: 12 additions & 0 deletions src/distributions/unit_sphere.rs
Expand Up @@ -77,4 +77,16 @@ mod tests {
assert_almost_eq!(x[0]*x[0] + x[1]*x[1] + x[2]*x[2], 1., 1e-15);
}
}

#[test]
fn value_stability() {
let mut rng = ::test::rng(2);
let dist = UnitSphereSurface::new();
assert_eq!(dist.sample(&mut rng),
[0.1660727273690104, 0.5202698793511903, 0.8376986939610902]);
assert_eq!(dist.sample(&mut rng),
[0.40052443371799834, 0.4237054996596154, -0.812436968356975]);
assert_eq!(dist.sample(&mut rng),
[0.9209910250970449, -0.32692477745072107, 0.21188610520628948]);
}
}

0 comments on commit 8d021a0

Please sign in to comment.