1. 25
blog.joeardent.net
1.

2. 9

It’s a surprisingly common thing to get this wrong the first time. See also http://mathworld.wolfram.com/SpherePointPicking.html.

1. 3

I think this also works: Pick longitude (0, pi). pick another angle (0, 2pi) for latitude and scale by sqrt(u) to avoid bunching at the poles. Pick radius (0,1) and scale by cube(u).

1. 2

What does the symbol u represent? And why doesn’t longitude run from 0 to 2π and latitude from 0 to π, instead of the other way around (as you have it)? The span of longitude should be bigger because it goes all the way around the sphere, while latitude just goes 1/2 of the way (from top to bottom).

1. 2

u is a randomly generated variable between zero and one. I think tedu mixed up longitude and latitude (he wouldn’t be the first one).

2. 1

Is this different from picking a random point in the spherical coordinate box and converting it to Cartesian ones?

1. 3

You can’t naively pick random spherical coordinators because they will clump together near the origin and around the poles.

3. 2

I really need to follow this up with corrections (Rust’s `rand` crate takes more than 2x the time to generate a Gaussian value vs. a uniform float between 0 and 1, for example). But it was still fun.

1. 2

This shows that if you randomly got, say, 0.2, it would get pushed to near 0.6. But if you got something close to 1, it won’t go past 1. In other words, this changes the distribution from uniform to… exponential? This is something I’m still unclear on.

No, it follows a power law, most likely approximating a Pareto distribution. What about it makes the author think it’s exponential?

1. 2

Author here: brain worms? Lack of training in probability and statistics? I went through a LOT of reading new-to-me things in the course of trying to figure all this out.

1. 1

Oh no I totally get that. My comment seems rather judge-y, I’m sorry if I came off that way. I admittedly learned an awful lot from reading your post, and I actually read up on the distribution you presented only after reading your article.

It appears similar to an exponential distribution on first sight from what I recall. It’s a lot harder to tell the difference when we’re restricted to such a limited section of the distribution.

1. 2

No worries! I had tried chasing down a Pareto-style function to make the correct distribution, but the relations among the parameters didn’t fit the constraints. But I was still unsure what to call the final, correct distribution, hence the question mark and caveat about my clarity :)

2. 1

I know it’s been a while, but I’ve updated this post to add a little clarity to the explanation of distributions (and gave a little shout-out to @nils and this thread!), and corrected the error about how long it takes to generate Gaussian vs. uniform random values.