pub fn sample_sphere_volume(
dim: usize,
n: usize,
radius: f64,
positive: bool,
seed: u64,
) -> IgraphResult<Vec<Vec<f64>>>Expand description
Sample points uniformly from the volume of a sphere.
Generates n points uniformly distributed inside a
dim-dimensional ball of the given radius, centered at the
origin. Uses sphere-surface sampling followed by radial scaling
U^(1/dim) where U ~ U(0,1).
If positive is true, all coordinates are mapped to their
absolute values (restricting to the positive orthant).
Returns a Vec<Vec<f64>> where each inner Vec has dim elements.
§Errors
Returns InvalidArgument if:
dim < 2radius <= 0
§Examples
use rust_igraph::sample_sphere_volume;
let points = sample_sphere_volume(2, 100, 1.0, false, 42).unwrap();
assert_eq!(points.len(), 100);
// All points inside the unit disk
for p in &points {
let r2: f64 = p.iter().map(|&x| x * x).sum();
assert!(r2 <= 1.0 + 1e-10);
}