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 (03 Feb 2024 19:14 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 03 Feb 2024 19:13 UTC

On 2/3/24 1:28 AM, Bradley Lucier wrote:
> I wrote the included test program that does the following:
>
> 1.  Creates a generator for an elliptical "ball" with semi-axes 10 and 2.
> 2.  Generates 100,000 points in the ellipse.
> 3.  Checks that (9.5, 0.5) is in the ellipse.
> 4.  Filters the points in two equal area regions within the ellipse,
>      $(-0.5, 0.5)\times(-0.5, 0.5)$ and $(8.5, 9.5)\times(-0.5, 0.5)$.
> 5.  Counts the number of points in each region.
>
> And I get 2280 for the first region and 973 for the second.

I did another, simpler test, with a two-dimensional ball (a disk):

(define c (make-ball-generator '#(10. 10.)))

(define ball-interior-points
   (map (lambda (x) (c)) (iota 100000)))

(display (length (filter (lambda (v)
                          (and (< -0.5 (vector-ref v 0) 0.5)
                               (< -0.5 (vector-ref v 1) 0.5)))
                          ball-interior-points)))
(newline)

(display (length (filter (lambda (v)
                            (and (< 8.5 (vector-ref v 0) 9.5)
                                 (< -0.5 (vector-ref v 1) 0.5)))
                          ball-interior-points)))
(newline)

This yields 452 and 236.  So the problem may not come from the
eccentricity of the first ellipse, because something screwy is going on
with the two-dimensional round disk, too.

Brad