[R] Worm distribution :-)

Jim Lemon jim at bitwrit.com.au
Tue Oct 24 12:44:11 CEST 2006


Alberto Monteiro wrote:
> I don't know if anyone has heard this tale, but it runs
> more or like this way:
> 
>   A biologist was studing a (semi-spherical) cave where bats
>   lives. He fell asleep in the cave, and he woke up in the
>   middle of the night. Half-dreaming, he thought that he was
>   outside, because glow-worms were living in the walls, and
>   they looked like stars. However, he noticed that, unlike a
>   real sky, these "stars" had no _pattern_: there were no
>   recognized images like The Cross, a Scorpion, The Hunter, etc.
> 
>   When he woke up, he conjectured that the reason we _can_
>   see patterns in the real sky is that the stars are randomly
>   distributed, while the glow-worms tried to keep a distance
>   to each other.
> 
> My question: what is the best way to generate a glow-worm-like
> distribution? I imagine that using a Latin Hypercube would
> leave too many holes in the (x,y) plane.
> 
Hi Alberto,

I once had to do this to generate "random dot stereograms" for 
perception experiments. One easy way is to build from one corner or edge 
(almost all these are rectangular, you can just clip out the figure you 
want later). The user defines a "hit" area for each successive point 
that contains the minimum and maximum allowable distances from the two 
nearest points (typically a small square). Points can be generated with 
two uniform random numbers having a mean of the distance to the center 
of the "hit" area and a range spanning the "hit" square. It was easy to 
churn out constrained random dot patterns on the fly with this method.

I no longer have the FORTRAN code that performed this, but I could 
probably knock it up in C or R if you're stuck for a method.

Jim



More information about the R-help mailing list