jos hendriks wrote:
Dear reader, hallo Morgan
notes: 1.The 50 is only there because then you get when using p1=(0,0) and sigma=(1,0), that's to say the standard normal distribution, directly something on the screen. If you don't put it in then you have only a part of the basin of attraction. 2.I don't know why you omit the fasctor .5 in the exonent of e. 3. I don't see any reason not to allow complex numbers for mean and variance. 4. I don't know ehy first squaring sigma and then take the squareroot of sigma
1 and 3 are pretty much answered by the original post. I didn't mess around with the definition much: 1 (-(x-mu)^2/(2 sigma^2)) p(x) = ------------------ e sqrt(2 pi sigma^2) Where sigma is the standard deviation, and mu the mean (which I called o for consistency with the others). My biggest fiddle was to chuck in a c parameter: c (-(x-o)^2/(2 sigma^2)) p(x) = ------------------ e sqrt(2 pi sigma^2) which in the julia sets is an arbitrary complex constant, and varies over the plane for the Mandelbrot. Short answer to 2 and 4: For 2, the factor is there if you look for it. For 4, the answer is because it's cheaper to compute that way. Longer answer to 2 and 4: Since c ------------------ sqrt(2 pi sigma^2) is constant, and the only place where c appears, I set c equal to that. c = {p3|pixel}/sqrt(2*pi*sqr(sigma)): z = c*exp(-sqr(z-o)/(2*sqr(sigma))) 2*sqr(sigma) appears twice, and it's constant, so it's (a) a waste of time computing it twice, and (b) a waste of time computing it inside the loop. So, pull it out into another constant, c1: c1 =2*sqr(sigma) c = {p3|pixel}/sqrt(pi*c1): z = c*exp(-sqr(z-o)/c1) The difference between sqrt(sqr(sigma)) and sigma is of course that for sigma real, sqrt(sqr(sigma)) is nonnegative. Using just sigma would (a) change the behaviour, and (b) mean an extra multplication in the initialiser, viz: c1 =2*sqr(sigma) c = {p3|pixel}/(sigma*sqrt(pi*2)): z = c*exp(-sqr(z-o)/c1) Morgan L. Owens "The bit that doesn't go away when you stop believing in it."