- #1
foxi
- 5
- 0
Hello!
Hope someone can help me, I already tried some solutions, but couldn't come to a final conclusion.
I need to create a circular area, from which particles are emitted. For this, I have a frequency distribution of x and y. I have around 100 points, but to simplify matters I list only some points.
e.g.
x(cm) with frequency
& y(cm)
-3 ......0.55
-2 ......0.8
-1 ......0.9
0 ......0.85
1 ......0.9
2 ......0.85
3 ......0.5
From these data, I see that the radius is 3. Now I need to create a circular area. I am doing this in Fortran.
So I calculate the cumulative sum of the frequency distribution and normalize it to 1. Then I let uniformly distributed random numbers "fall in this table" and get my distribution in x and y.
Now comes the tricky part for me. I have to assign to each x the proper y (that the desired distribution is fulfilled) and get the circular area.
I know the formulas x_coordinate=R*cos(2pi*randomNumber) and y_coordinate=sin(2pi*randomNumber), but by using that (taking the x and y as the radius R), the coordinates are concentrated in the circle center.
So I started to "play" with x=sqrt(R^2-y^2) and R=sqrt(x^2+y^2), but I don't get the circle area with the distribution.
How can I sample a circular surface following a given distribution of x and y values? I hope I could describe the problem properly.
Thank you in advance.
Hope someone can help me, I already tried some solutions, but couldn't come to a final conclusion.
I need to create a circular area, from which particles are emitted. For this, I have a frequency distribution of x and y. I have around 100 points, but to simplify matters I list only some points.
e.g.
x(cm) with frequency
& y(cm)
-3 ......0.55
-2 ......0.8
-1 ......0.9
0 ......0.85
1 ......0.9
2 ......0.85
3 ......0.5
From these data, I see that the radius is 3. Now I need to create a circular area. I am doing this in Fortran.
So I calculate the cumulative sum of the frequency distribution and normalize it to 1. Then I let uniformly distributed random numbers "fall in this table" and get my distribution in x and y.
Now comes the tricky part for me. I have to assign to each x the proper y (that the desired distribution is fulfilled) and get the circular area.
I know the formulas x_coordinate=R*cos(2pi*randomNumber) and y_coordinate=sin(2pi*randomNumber), but by using that (taking the x and y as the radius R), the coordinates are concentrated in the circle center.
So I started to "play" with x=sqrt(R^2-y^2) and R=sqrt(x^2+y^2), but I don't get the circle area with the distribution.
How can I sample a circular surface following a given distribution of x and y values? I hope I could describe the problem properly.
Thank you in advance.