Sample implementation of make-ball-generator seems incorrect Bradley Lucier (03 Feb 2024 06:28 UTC)
Re: Sample implementation of make-ball-generator seems incorrect Bradley Lucier (04 Feb 2024 20:08 UTC)
Re: Sample implementation of make-ball-generator seems incorrect Arthur A. Gleckler (05 Feb 2024 00:47 UTC)

Re: Sample implementation of make-ball-generator seems incorrect Bradley Lucier 04 Feb 2024 20:08 UTC
I may have sorted some things out.

The file sphere-uniform.scm contains some more tests for generating
points uniformly inside a ball and an ellipsoid.  It also contains a
minimal test for uniform distribution of points around an ellipse, which
the sample implementation passes (visually), while failing all the
interior tests.

I include a rewritten sphere.scm.  Many of the changes are a matter of
style, but there are two substantive ones:

1.  In make-ellipsoid-generator* there is

   (define gaussg-vec
     (make-vector (vector-length axes) (make-normal-generator 0 1)))

This puts the same copy of the generator into all slots of gauss-vec
(they're all eq?).  I replaced this with a single generator.
Statistically, it doesn't matter that there's only one generator for all
coordinates.

2.  I replaced make-ball-generator with an algorithm from

https://www.onera.fr/sites/default/files/297/C013_-_Dezert_-_YBSTributeMonterey2001.pdf

which is itself incorrect (as a failing test shows) even thought it's
cited all over the interwebs.

After some googling I know of no method of uniformly sampling points
inside an ellipsoid other than generating them inside a bounding
hyperbox and testing whether they're inside the ellipsoid, which is
basically impossibly inefficient when the dimension is as small as 10
(see Figure 1 in the above paper).  The paper's method, which I
implemented, is efficient but generates points that are not completely
uniform.

So, how to proceed?  Don't include make-ball-generator with unequal
semi-axes?  Find a better algorithm? Or something else?

Brad