Generate uniformly distributed points within an ellipse

marginal-distributionprobabilityprobability theory

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}[1]{\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.
enter image description here

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).

Best Answer

In a 2D case, generating a random point in a bounding rectangle and throwing away points outside the ellipse isn't that ineffective. However, it is very ineffective if you generalise it for high dimension. I will tell you a way which is intuitive, effective for high dimension and it is guaranteed to terminate in fixed time.

You imagine that the ellipse is a bottle. You calculate the volume and you spill random amount of water into the bottle. The random point you are looking for is somewhere on the level of water. In this case, it is a line. This way, the task reduced by one dimension. Next thing you have to do is choosing a random point of the line you got, which is trivial.

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.

You can use the same trick for other shapes also, for example simplexes.