Sample circle area following a distribution

9 replies · 3K views · last reply
foxi
Messages
5
Reaction score
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.
 
Let me try to clarify what you are asking.

My interpretation is that you have an empirical distribution of a some quantity (particle emission density) as a function of a single distance measurement.

You want to find a two dimensional distribution on a circle of radius 3 in the XY plane. Are you trying to make the distribution of emission density with respect to a radial distance within the circle agree with the empirical distribution?

Or are you trying to make the marginal distributions with respect to both X and Y agree with the empirical distribution?
 
Hello Stephen!

Yes, I am asking for the first point you wrote:

Stephen Tashi said:
Let me try to clarify what you are asking.

My interpretation is that you have an empirical distribution of a some quantity (particle emission density) as a function of a single distance measurement.

You want to find a two dimensional distribution on a circle of radius 3 in the XY plane. Are you trying to make the distribution of emission density with respect to a radial distance within the circle agree with the empirical distribution?

Yes, the measured data present some emission density. In reality particles are emitted from a circular surface. The data in the table (from my first post) have been measured along the x and y-axis (horizontal and vertical axis). I interpolated these data and have around 100 data points (here I showed only, how the table looks like).
This is why I first assumed the "x" & "y" data as the radius. I sampled this distribution (by making the cumulative sum of the frequency distribution) and calculated x= R * cos (2*pi*randomNumber) and y= R * sin (2*pi*randomNumber). I get my circle, but the data are concentrated in the center and decrease to the border. Usually the Radius should decrease by sqrt(R) to receive a uniform distribution within a circle.
But I think in this case, it is not very simple to sample the sqrt(R).

So I switched to another possible solution:
I tried to assign to each "x" with the distribution the proper "y" with the distribution. Therefore I sampled again the distribution, but then I said that I get the "x" and calculated y=sqrt(R^2-x^2) with R=3. This doesn't really work, because I didn't know where to include the random number.

I always switched between these two methods (still don't know which one is the proper one...or which one really works...or is it a combination of both), so I kindly ask for some advice.
Thank you!
 
foxi said:
Hello Stephen!

Yes, I am asking for the first point you wrote:

<snip>
Yes, the measured data present some emission density. In reality particles are emitted from a circular surface. The data in the table (from my first post) have been measured along the x and y-axis (horizontal and vertical axis).

From those statements, I still do not understand the table. Is the left hand column of the table a radial distance? If so, why does it have some negative values?

Or is the left hand column of the table an X distance or a Y distance? If so, why is there only one column? Why not (X,Y) in two columns? Is the table a marginal distribution for X and we assume the marginal distribution for Y is the same distribution?
 
Hello!

The values of emission density have been measured along x and y (horizontal and vertical axes). The x-data are measured along y=0 and vice versa. The center of the circle is zero, this explains why there are also minus values.
It is known that particles are emitted from a circle surface, but only the values of the "circle axes" are known.

There is only one column, because the emission density measured along x and y are the same. This is also why I was writing about a radial distance. We can call the horizontal and vertical axes also in a different way, e.g. a and b.

I am sorry for causing confusion.
 
I understand the table better. However, I don't know much about particle emission. Let's say we have a unit circle and there is a particle emitted at the point x = 2/3,y = 1/3 within that circle. Does particle fly away from that point in a straight line at some random direction? Can I visualize the detector as an array of hit-vs-no-hit detectors sitting along the x-axis? Can the particle emitted at (2/3,1/3) hit the x-axis (the detector) at some x value that may be different than x = 2/3? If the particle is detected by a detector along the x-axis, is it "captured" and prevented from also triggering a detector on the y-axis?
 
Yes, the particle is emitted from a point from the circle surface and is flying in a straight line perpendicular to the circle area.
In reality the "circle area" is not a detector; it is a particle source. So if a particle is emitted at (2/3, 1/3) from the (x,y) plane it is leaving the area exactly from that point.
I am doing this for an input for a MC simulation.
I don't know how to do the procedure of sampling x and y. I mean, saying in my fortran program that it should sample x and y from the given distribution.
 
Let [itex]f(x,y)[/itex] be the joint probability density. I think your are saying that your data gives the marginal density [itex]f_x(x,y) = \int_{-3}^3 f(x,y) dy [/tex], which we assume is the same function as the marginal density [itex]f_y(x,y) = \int_{-3}^3 f(x,y) dx[/itex].<br /> <br /> This resembles the situation in a 2-D tomography problem. When we are given only the marginal densities, these usually don't determine a unique answer for [itex]f(x,y) [/tex]. If we add the assumption that [itex]f(x,y)[/itex] is constant on the concentric circles, then it may be possible to solve for a unique [itex]f(x,y)[/itex]. However, this would imply that the marginal distributions should be symmetric about 0 and there is a slight asymmetry to the data in your table. <br /> <br /> If you already have a specific [itex]f(x,y)[/itex] in mind, I can explain how to draw a random pair (x,y) from it.[/itex][/itex]
 
I understand the difficulty of drawing a pair (x,y) on the concentric circles with this asymmetric data, because it is not solvable in a unique way as you said.
But let’s assume I could choose the random pair (because in reality the truth is not known). How could I sample then x and y?
 
As I said, we must assume that you know the joint probability density [itex]f(x,y)[/itex]

Then we can find marginal density with respect to [itex]x[/itex]:

[itex]f_x(x) = \int_{-3}^3 f(x,y) dy[/itex]

and the cumulative marginal distribution with respect to [itex]x[/itex]

[itex]F_x(x) = \int_{-3}^x f_x(x) dx[/itex]

and the conditional density of [itex]y[/itex] given [itex]x[/itex]:

[tex]g(y,x) = \frac{f(x,y)}{C} [/itex] where [itex]C = \int_{-3}^{3} f(x,y) dx[/itex]<br /> <br /> and the cumulative conditional distribution of [itex]y[/itex] given [itex]x[/itex]:<br /> <br /> [itex]G(y,x) = \int_{-3}^y g(y,x) dy[/itex]<br /> <br /> For a fixed value of [itex]x = x_0[/itex] , [itex]G[/itex] defines a function of [itex]y[/itex] alone, which will be denoted as [itex]G(y,x_0)[/itex].<br /> <br /> ( I am using the limits of integration -3 to 3 with the understanding that [itex]f(x,y)[/itex] must be defined to be zero for y values that are outside the boundaries of the circle. A more complicated way to write integration for G woud be set the lower limit of integration with respect to y to the smallest y that is within the circle by expressing that limit as a function of x.)<br /> <br /> To draw a random sample [itex](x0,y0)[/itex]:<br /> <br /> Draw [itex]u_1[/itex] from a uniform distribution on [0,1].<br /> <br /> Set [itex]x_0 = F^{-1}(u_0)[/itex][/tex][itex] <br /> Draw [itex]u_2[/itex] from a uniform distribution on [0,1].<br /> <br /> Set [itex]y_0 = G^{-1}(u_1,x_0)[/itex] (i.e. find the value of [itex]y[/itex] where [itex]G(y,x_0) = u_2[/itex] )[/itex]