Hacker News new | past | comments | ask | show | jobs | submit login

> First we make N complex values from polar coordinates that have a random angle 0 to 2pi and a random radius from 0 to 1.

This is what jumped out to me as suspicious. This looks just like a naive (and wrong) algorithm for generating random points in a circle. The simplest correct way to do this in the circle case is rejection sampling. In this context, that would mean: generate a random real and imaginary part to get z, and retry until |z| ≤ 1.




The goal is not well-defined here. If the goal is to generate uniformly-distributed points in a circle then this algorithm is wrong, but it’s not clear that’s actually what they want.

Generating a spectrum with a given magnitude distribution and uniform phase distribution is pretty common (at least in audio).


Yes, though e.g. if you want white nose you'd use a Rayleigh distribution for magnitude rather than a Gaussian as you would use for real and imaginary parts.


Then simplest way to do so is to sample a normal distribution twice and normalize the length. Its significantly faster too.


That gives r=1. They want r<=1.


Ah missed that




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: