Asked by adameye adameye
on 30 Apr 2013

Hi: I am trying to simulate a galaxy distribution, in which all units are identical, but the local densities are different. Simply speaking, I need to produce a 2-D point distribution, say, 1000 identical points in a 10*10 square, then if I measure the local densities (for example, within a circle with radius=1), I could get a normal distribution of densities.

Maybe I did not explain it clearly, but just do not know how to do it, I can easily generate a data set with normal distribution value, but how to apply normal distribution on the position of 2-D points (move some together and take some apart) to get normal density distribution? thanks!

*No products are associated with this question.*

Answer by Iman Ansari
on 1 May 2013

With adding a number in x and y directions you can change their position, and the number multiplied changes their radius:

A=randn(3000,2); x=A(:,1)'; y=A(:,2)'; x=[x(1:800)+3 1/2.*x(801:1800)-3 1.5.*x(1801:3000)+2]; y=[y(1:800)+4 1/2.*y(801:1800) 1.5.*y(1801:3000)-3]; plot(x,y,'Marker','.','LineStyle','none') axis('equal') var(x)+1i*var(y) mean(x)+1i*mean(y)

Answer by adameye adameye
on 1 May 2013

Thanks a lot, This is a different way to solve the problem.

btw, do you know how to produce the needed distribution from power spectrum? because in cosmos people normaly make gaussian simulation a kind of stationary distributing (Cov(x,y)==Cov(x+u,y+u), only related with the distance between x and y, not relation with the shift u), in other words, the distribution will look like no obvious center....

thanks again

Answer by adameye adameye
on 14 May 2013

Hi: Sorry I have to read some articles to investigate this problem and it took long time, I got http://www.astro.rug.nl/~weygaert/tim1publication/lss2007/computerIII.pdf I am still trying to understand the right procedure.... thank you very much! "

4 Generating Gaussian eld in Fourier Space
Generating a Random Gaussian eld is easiliest done in Fourier space. Then
the complex Fourier amplitudes are Y~ = `Y~` exp(i*phi). Where is a random
phase and the modules are Rayleigh distributed

f(x) =2x/(sigma^2)*exp(-x^2/sigma^2)

The dispersion is of course related to the Power Spectrum as

sigma^2=(delat_k^3)*P(k) "

Opportunities for recent engineering grads.

## 2 Comments

## Iman Ansari (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/74052#comment_146311

See this: (mean zero and variance 1)

## adameye adameye (view profile)

Direct link to this comment:http://www.mathworks.com/matlabcentral/answers/74052#comment_146515

thanks, this is very interesting, but this data looks like one "big ball", right? If I want to have a full pic of data, with points cluster somewhere, voids somewhere, how can I do it? Maybe I can combine some of those results to get a pic with a bunch of "big balls"? thanks again!