1

Question

I have an ellipsoid represented as a Covariance $\Sigma \in \mathbb{R}^{3\times3}$ and a mean centroid $\mu\in \mathbb{R}^{3}$. I want to represent it as a homogenous quadric, which is a $4\times4$ symmetric matrix. A quadric fulfills the property $\hat{x}^{\top}Q\hat{x}=0$ for all points $\hat{x} = [x^\top;1]^{\top}$ on the surface of the ellipsoid.

Background

This post describes how to convert a Covariance to quadric form but assumes $\mu=0$. I tried setting $b=\mu, c=-1$, but that does not work.

I specifically need it in this form, as I want to project in onto a conic like so $C^{*}=PQ^{*}P^\top$ in the next step.

Does anyone know how to adapt the quadric if the Ellipsoid is not zero-centered?

Update

I tried to derive the Quadric parametrization from a given $(\Sigma, \mu)$.

We can define the $\sigma$-surface of this ellipsoid:

$$(x-\mu)^\top\Sigma^{-1}(x-\mu)-\sigma=0$$

It can also be described with the general quadric equation:

$$x^{\top}Ax+2b^{\top}x+c=0$$

By multiplying out the first equation and comparing the constant, linear and quadratic terms, the following correspondances between the parameters can be established:

$$A=\Sigma^{-1}, b=-A\mu ,\; c=\mu^⊤\mu-\sigma$$

The general quadric equation can be expressed more compact with homogenous formulation:

$$Q = \begin{bmatrix}A & b \\ b^⊤ & c\end{bmatrix}, $$ $$ \hat{x}^{\top}Q\hat{x}=0, \hat{x}=[x^{\top},1]^{\top}$$

Remaining Problem (Example)

For an axis-aligned, non zero-centered Ellipsoid parametrized by

$$\Sigma=\begin{bmatrix}2 & 0 & 0\\ 0 & 1 & 0 \\ 0 & 0 & 1\end{bmatrix}, \mu=[1, 1, 1]^\top$$

the resulting quadric looks like this

$$Q=\begin{bmatrix} 0.5 & 0 & 0 & -0.5\\ 0 & 1 & 0 & -1 \\ 0 & 0 & 1 & -1\\ -0.5 & -1 & -1 & 2 \end{bmatrix}$$.

The problem is, that the equation $\hat{x}^{\top}Q\hat{x}=0$ is not fulfilled anymore:

$$\hat{x} = [3, 1, 1, 1]\rightarrow \hat{x}^{\top}Q\hat{x}= 1.5$$ $$\hat{x} = [1, 2, 1, 1]\rightarrow \hat{x}^{\top}Q\hat{x}= 0.5$$ $$\hat{x} = [1, 1, 2, 1]\rightarrow \hat{x}^{\top}Q\hat{x}= 0.5$$

Am I missing something? This Colab Notebook shows the code I used to test this all. Feel free to leave a comment.

2 Answers2

1

Ah! you are all perfectly correct till the last few equations. One of the three probe points is wrong, it's not on the ellipsoid, so it got a different value.

The correct coordinate for the first point shall be $$ \hat{x} = [1+\sqrt 2, 1, 1, 1]\rightarrow \hat{x}^{\top}Q\hat{x}= 0.5 $$

Key is to notice, $\Sigma$ is the covariance, not standard deviation, the extant of the axis shall be sqrt ed.


In your code, this line is wrong

ellipsoid_m1 = (Sigma @ unit_sphere_ijk) + mu[:, np.newaxis]

Recall that to generate a Gaussian random variable of covariance $\Sigma$, you should not use $\Sigma$ to transform standard Gaussian. Instead you need to use its Cholesky factor to transform the standard normal variable. $$ \Sigma=AA^T\\ z\sim N(0,I)\\ Az\sim N(0,AA^T) $$


Really nice that you provide that well made colab notebook! it makes verifying your work super easy.

  • Hey thanks for catching that mistake with the radii. Still, the equation evaluates to 0.5 whereas I would expect it to become zero. How would I need to adapt the sampling kn the ellipsoid? I don't get your remarks on the Cholesky Faktor. Thank you for your answer! – rohlemax May 16 '22 at 05:06
  • 1
    Factorize your matrix $\Sigma=AA^T$, then use the factor to generate your sample.

    Sample $z\sim N(0,I)$ standard Gaussian, then map it to $x=Az+\mu$ then $x\sim N(\mu,\Sigma)$ is distributed as the ellipsoidal Gaussian as you need. you can generate $|z|=1$, then $Az$ is the equidensity ellipsoid.

    – Binxu Wang 王彬旭 May 16 '22 at 05:13
  • Thanks! Now with the cholesky factor, the on_ellipsoid method checks out for all samples on the ellipsoid. Do you have a clue, why $x^{T}Qx=0.5$ and not $0$ as expected? – rohlemax May 16 '22 at 13:46
  • Update: I found an error in my calculations of $c$. I will write a detailed answer... – rohlemax May 16 '22 at 15:58
  • @rohlemax I think it equals 0.5 is kind of artibtrary. as long as it's not 0 which results in a point not a ellipsoid – Binxu Wang 王彬旭 May 16 '22 at 16:19
  • 1
    No, the $0.5$ thing traces back to an error in the computation of $c$; see my updated answer. Thanks for pointing out the Cholesky Faktor! I have been sampling ellipsoidal-surfaces wrong for so long now :D In most cases, it doesnt really matter as long as its done consistently. – rohlemax May 16 '22 at 16:21
  • Yeah. In your way you are defining a ellipsoid with $\Sigma\Sigma$ covariance... which is a valid ellipsoid too. – Binxu Wang 王彬旭 May 16 '22 at 16:24
1

Derivation error

First there is an error in the derivation of the coefficient $c$. The general form:

$$(x-\mu)^\top\Sigma^{-1}(x-\mu)-\sigma=0$$

multiplies out to

$$x^{\top}\Sigma^{-1}x-2\mu^{\top}\Sigma^{-1}x+\mu^{\top}\Sigma^{-1}\mu-\sigma=0$$

which yields the coefficients by comparison

$$A=\Sigma^{-1}, b=-\Sigma^{-1}\mu ,\; c=\mu^⊤\Sigma^{-1}\mu-\sigma$$

Eigenvalue vs. Radius

As pointed out by @Binxu Wang in her answer the samples on the $\sigma$-surface of an ellipsoid with known Covariance $\Sigma$ are obtained from the samples on the unit-sphere $\hat{x}$ by

$$x = L\hat{x} + \mu$$

where L is the Cholesky Decomposition of $\Sigma$

$$\Sigma = LL^{\top}$$

Sampling with $\Sigma$ instead of $L$ would give points on the $\sigma^2$-surface of the ellipsoid.

Result

I verified, that all samples on the Ellipsoid fulfill $x^{\top}Qx=0$.