sphereVariable

Uniform distribution on a sphere.

  1. struct SphereVariable(T)
  2. SphereVariable!T sphereVar()
  3. alias sphereVariable = sphereVar
    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