# How to generate uniformly distributed points within an ellipse?

I am give a sequence of tasks. The each next task is the continuation of the previous one. I managed to solve all of them, except the last. In the first two tasks I was asked to find marginal distributions, expected value of the random vector and variance-covariance matrix. $$\newcommand{\u}{\underline{#1}} p(x) = \begin{cases} 1/\pi,\text{ if }x_1^2 + x_2^2 < 1 \\ 0, \text{ otherwise} \end{cases}$$ $$p_\underline{x_1} = \int_{-\sqrt{1 - x_1^2}}^{\sqrt{1 - x_1^2}} \frac{1}{\pi} dx_2 = \frac{2}{\pi}\sqrt{1 - x_1^2}$$

$$p_\underline{x_2} = \int_{-\sqrt{1 - x_2^2}}^{\sqrt{1 - x_2^2}} \frac{1}{\pi} dx_1 = \frac{2}{\pi}\sqrt{1 - x_2^2}$$ $$\mathbb{E}(\underline x) = \begin{bmatrix} 0 \\ 0 \end{bmatrix}$$ $$Var(\underline{x}) = \begin{bmatrix} \frac{1}{4} & 0 \\ 0 & \frac{1}{4} \end{bmatrix}$$ For the next tasks I have the linear transformation of the random vector. Again I have to find the expected value, variance-covariance matrix and using Chebyshev inequality find the radius where at least 90% of probability is: $$\u{y} = \begin{bmatrix} 1 & -1 \\ 0 & 2 \end{bmatrix} \u{x} + \begin{bmatrix} 2 \\ 3 \end{bmatrix} \\$$ $$\mathbb{E}(b + A\u{x}) = \begin{bmatrix} 2 \\ 3 \end{bmatrix}$$ $$Var(b + A\u{x}) = \begin{bmatrix} \frac{1}{2} & -\frac{1}{2} \\ -\frac{1}{2} & 1 \end{bmatrix}$$ $$P(||\u{x} - \mathbb{E}(\u{x})||^2 < \frac{tr(var(\u{x}))}{1 - \alpha}) \ge \alpha => \text{ radius } = \sqrt{15}$$ Lastly I am asked to plot with equal axis (it will look like a circle) the points of the linearly transformed distribution and the circle with the calculated radius. This is the task where I am stuck. I generated points uniformly within Chebyshev's radius. Plot on the left is the stretched circle and on the right is the same with equal axes. The plots contain 90% of the data. So I have to plot the rest 10%, which must be outside the circle/ellipse. I imagined that this transformation stretches the unit circle into an ellipse. In the case of unit circle I can generate points from uniform distribution values between -1 and 1. How to determine the range in the case of the ellipse? What is this radius then? Is there any connection with eigen vectors? Sure, I can generate points within the unit circle and then transform them with the matrix given, but I think this is not the solution, which I have to provide. I provided all previous tasks and answers because there must be connection (I think).

• Why not generate random points in the rectangle that contains the ellipse, and then throw out any points that land outside the ellipse? It's not the most efficient, but it's the easiest solution. Jan 7 at 19:58
• I think that I have to provide an analytical solution for that. Because of this the question is here. I can generate the point in a way you told but the question about the actual radius is torturing me. Jan 7 at 20:00
• Another approach would be to work backward from the solution. If you want points evenly spaced in the vertical and horizontal directions after stretching the vertical direction, then you just need to make the initial distribution more dense in the vertical direction so when it is stretched, the 2D distribution is uniform. Jan 7 at 20:14
• Thank you for your hint, but I am not sure that I understood what do you mean. Could you please provide some link, where I could read about that? Jan 7 at 20:16
• Suppose that you want your uniform distribution to have $x$ points per unit length in the horizontal and vertical directions. If you generate a distribution in this way and then stretch the vertical direction by a factor $K$, then you will have $x$ points per unit length in the horizontal direction and $x/K$ per unit length in the vertical direction. To fix this, generate an initial distribution with $x$ per unit length in the horizontal direction and $Kx$ per unit length in the vertical direction, and then stretch. The result will have $x$ per unit length in both directions. Jan 7 at 20:28

The same thing more formally: You choose the $$x$$-coordinate by the marginal distribution $$p(x)$$. After that, you choose the $$y$$-coordinate by the distribution given $$x$$, i.e. $$p(y|x)$$. And you are done.