The OpenD Programming Language

sphereVariable

Uniform distribution on a sphere.

import mir.random.ndvariable;
alias sphereVariable = sphereVar

Return Value

X ~ 1 with X[0]^^2 + .. + X[$-1]^^2 = 1

Examples

Generate random points on a circle

import mir.random.engine;
import mir.math.common: fabs;

double[2] x;
sphereVar()(rne, x);
assert(fabs(x[0] * x[0] + x[1] * x[1] - 1) < 1e-10);

Meta