Why is the number of non zero eigenvalues equal to $x^T Sigma^{-1} x$












0














I've been reading this code and I found that the number of non-zero eigenvalues of the estimated covariance is equal to $x_i^T Sigma^{-1} x_i$. I want to know how to arrive at this result.



Some background:





  • $x_i$ is a real column vector with dimension $d$ (one sample)


  • $X = [x_1, x_2, ..., x_n]$ with shape $d$x$n$ (all the samples)


I want to prove that:
$$sum_{i=0}^{i=n} x_i^T Sigma^{-1} x_i = n.len(s)$$
being $len(s)$ the number of non-zero singular values* of $Sigma$, that is defined as
$$Sigma = frac{1}{n} sum_{j=1}^{j=n} x_j x_j^T$$



If necessary, mean can be considered $0$



*Not necessarily mathematical $0$, this can also mean "not too small values" .

Actually non-zero is "non-negligible" depending on a threshold defined as the largest singular value times the square root of the machine epsilon.

In Python: s[0] * np.sqrt(np.finfo(np.float).eps) being s the singular values in descending order (see the code)










share|cite|improve this question






















  • How do you propose to compute $Sigma^{-1}$ if $Sigma$ has zero singular values? Otherwise, this is just a trace identity. The answer should always be $n$.
    – Hans Engler
    Nov 16 '18 at 21:54










  • In fact, the question is about the proposal itself. The code I'm looking into, and this other R package, assume the proposition that involves $n. len(s)$. I want to know when it's valid, and what approximations and assumptions are being made. Sorry if it wasn't clear
    – Franco Marchesoni
    Nov 19 '18 at 21:07
















0














I've been reading this code and I found that the number of non-zero eigenvalues of the estimated covariance is equal to $x_i^T Sigma^{-1} x_i$. I want to know how to arrive at this result.



Some background:





  • $x_i$ is a real column vector with dimension $d$ (one sample)


  • $X = [x_1, x_2, ..., x_n]$ with shape $d$x$n$ (all the samples)


I want to prove that:
$$sum_{i=0}^{i=n} x_i^T Sigma^{-1} x_i = n.len(s)$$
being $len(s)$ the number of non-zero singular values* of $Sigma$, that is defined as
$$Sigma = frac{1}{n} sum_{j=1}^{j=n} x_j x_j^T$$



If necessary, mean can be considered $0$



*Not necessarily mathematical $0$, this can also mean "not too small values" .

Actually non-zero is "non-negligible" depending on a threshold defined as the largest singular value times the square root of the machine epsilon.

In Python: s[0] * np.sqrt(np.finfo(np.float).eps) being s the singular values in descending order (see the code)










share|cite|improve this question






















  • How do you propose to compute $Sigma^{-1}$ if $Sigma$ has zero singular values? Otherwise, this is just a trace identity. The answer should always be $n$.
    – Hans Engler
    Nov 16 '18 at 21:54










  • In fact, the question is about the proposal itself. The code I'm looking into, and this other R package, assume the proposition that involves $n. len(s)$. I want to know when it's valid, and what approximations and assumptions are being made. Sorry if it wasn't clear
    – Franco Marchesoni
    Nov 19 '18 at 21:07














0












0








0







I've been reading this code and I found that the number of non-zero eigenvalues of the estimated covariance is equal to $x_i^T Sigma^{-1} x_i$. I want to know how to arrive at this result.



Some background:





  • $x_i$ is a real column vector with dimension $d$ (one sample)


  • $X = [x_1, x_2, ..., x_n]$ with shape $d$x$n$ (all the samples)


I want to prove that:
$$sum_{i=0}^{i=n} x_i^T Sigma^{-1} x_i = n.len(s)$$
being $len(s)$ the number of non-zero singular values* of $Sigma$, that is defined as
$$Sigma = frac{1}{n} sum_{j=1}^{j=n} x_j x_j^T$$



If necessary, mean can be considered $0$



*Not necessarily mathematical $0$, this can also mean "not too small values" .

Actually non-zero is "non-negligible" depending on a threshold defined as the largest singular value times the square root of the machine epsilon.

In Python: s[0] * np.sqrt(np.finfo(np.float).eps) being s the singular values in descending order (see the code)










share|cite|improve this question













I've been reading this code and I found that the number of non-zero eigenvalues of the estimated covariance is equal to $x_i^T Sigma^{-1} x_i$. I want to know how to arrive at this result.



Some background:





  • $x_i$ is a real column vector with dimension $d$ (one sample)


  • $X = [x_1, x_2, ..., x_n]$ with shape $d$x$n$ (all the samples)


I want to prove that:
$$sum_{i=0}^{i=n} x_i^T Sigma^{-1} x_i = n.len(s)$$
being $len(s)$ the number of non-zero singular values* of $Sigma$, that is defined as
$$Sigma = frac{1}{n} sum_{j=1}^{j=n} x_j x_j^T$$



If necessary, mean can be considered $0$



*Not necessarily mathematical $0$, this can also mean "not too small values" .

Actually non-zero is "non-negligible" depending on a threshold defined as the largest singular value times the square root of the machine epsilon.

In Python: s[0] * np.sqrt(np.finfo(np.float).eps) being s the singular values in descending order (see the code)







linear-algebra eigenvalues-eigenvectors covariance data-analysis maximum-likelihood






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Nov 16 '18 at 21:33









Franco Marchesoni

32




32












  • How do you propose to compute $Sigma^{-1}$ if $Sigma$ has zero singular values? Otherwise, this is just a trace identity. The answer should always be $n$.
    – Hans Engler
    Nov 16 '18 at 21:54










  • In fact, the question is about the proposal itself. The code I'm looking into, and this other R package, assume the proposition that involves $n. len(s)$. I want to know when it's valid, and what approximations and assumptions are being made. Sorry if it wasn't clear
    – Franco Marchesoni
    Nov 19 '18 at 21:07


















  • How do you propose to compute $Sigma^{-1}$ if $Sigma$ has zero singular values? Otherwise, this is just a trace identity. The answer should always be $n$.
    – Hans Engler
    Nov 16 '18 at 21:54










  • In fact, the question is about the proposal itself. The code I'm looking into, and this other R package, assume the proposition that involves $n. len(s)$. I want to know when it's valid, and what approximations and assumptions are being made. Sorry if it wasn't clear
    – Franco Marchesoni
    Nov 19 '18 at 21:07
















How do you propose to compute $Sigma^{-1}$ if $Sigma$ has zero singular values? Otherwise, this is just a trace identity. The answer should always be $n$.
– Hans Engler
Nov 16 '18 at 21:54




How do you propose to compute $Sigma^{-1}$ if $Sigma$ has zero singular values? Otherwise, this is just a trace identity. The answer should always be $n$.
– Hans Engler
Nov 16 '18 at 21:54












In fact, the question is about the proposal itself. The code I'm looking into, and this other R package, assume the proposition that involves $n. len(s)$. I want to know when it's valid, and what approximations and assumptions are being made. Sorry if it wasn't clear
– Franco Marchesoni
Nov 19 '18 at 21:07




In fact, the question is about the proposal itself. The code I'm looking into, and this other R package, assume the proposition that involves $n. len(s)$. I want to know when it's valid, and what approximations and assumptions are being made. Sorry if it wasn't clear
– Franco Marchesoni
Nov 19 '18 at 21:07










1 Answer
1






active

oldest

votes


















0














Assuming that the sample ${x_i}$ spans the whole space $mathbb{R}^d$, the value is always $nd$. Here is the proof:



Using your notation for $X$, we know $Sigma = frac{1}{n} XX^T$ and therefore $Sigma^{-1} = n left(XX^T right)^{-1}$. Then
$$
x_i^T Sigma^{-1} x_i = tr(x_i^T Sigma^{-1} x_i) =
tr(Sigma^{-1} x_i x_i^T)
$$


and therefore
$$
sum_{i = 1}^n x_i^T Sigma^{-1} x_i = tr(Sigma^{-1} sum_{i=1}^n x_i x_i^T)
= tr(Sigma^{-1} (XX^T)) = n tr(I_d) = nd
$$

where $I_d$ is the $d$-dim identity matrix.






share|cite|improve this answer





















    Your Answer





    StackExchange.ifUsing("editor", function () {
    return StackExchange.using("mathjaxEditing", function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
    StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
    });
    });
    }, "mathjax-editing");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "69"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    noCode: true, onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3001665%2fwhy-is-the-number-of-non-zero-eigenvalues-equal-to-xt-sigma-1-x%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Assuming that the sample ${x_i}$ spans the whole space $mathbb{R}^d$, the value is always $nd$. Here is the proof:



    Using your notation for $X$, we know $Sigma = frac{1}{n} XX^T$ and therefore $Sigma^{-1} = n left(XX^T right)^{-1}$. Then
    $$
    x_i^T Sigma^{-1} x_i = tr(x_i^T Sigma^{-1} x_i) =
    tr(Sigma^{-1} x_i x_i^T)
    $$


    and therefore
    $$
    sum_{i = 1}^n x_i^T Sigma^{-1} x_i = tr(Sigma^{-1} sum_{i=1}^n x_i x_i^T)
    = tr(Sigma^{-1} (XX^T)) = n tr(I_d) = nd
    $$

    where $I_d$ is the $d$-dim identity matrix.






    share|cite|improve this answer


























      0














      Assuming that the sample ${x_i}$ spans the whole space $mathbb{R}^d$, the value is always $nd$. Here is the proof:



      Using your notation for $X$, we know $Sigma = frac{1}{n} XX^T$ and therefore $Sigma^{-1} = n left(XX^T right)^{-1}$. Then
      $$
      x_i^T Sigma^{-1} x_i = tr(x_i^T Sigma^{-1} x_i) =
      tr(Sigma^{-1} x_i x_i^T)
      $$


      and therefore
      $$
      sum_{i = 1}^n x_i^T Sigma^{-1} x_i = tr(Sigma^{-1} sum_{i=1}^n x_i x_i^T)
      = tr(Sigma^{-1} (XX^T)) = n tr(I_d) = nd
      $$

      where $I_d$ is the $d$-dim identity matrix.






      share|cite|improve this answer
























        0












        0








        0






        Assuming that the sample ${x_i}$ spans the whole space $mathbb{R}^d$, the value is always $nd$. Here is the proof:



        Using your notation for $X$, we know $Sigma = frac{1}{n} XX^T$ and therefore $Sigma^{-1} = n left(XX^T right)^{-1}$. Then
        $$
        x_i^T Sigma^{-1} x_i = tr(x_i^T Sigma^{-1} x_i) =
        tr(Sigma^{-1} x_i x_i^T)
        $$


        and therefore
        $$
        sum_{i = 1}^n x_i^T Sigma^{-1} x_i = tr(Sigma^{-1} sum_{i=1}^n x_i x_i^T)
        = tr(Sigma^{-1} (XX^T)) = n tr(I_d) = nd
        $$

        where $I_d$ is the $d$-dim identity matrix.






        share|cite|improve this answer












        Assuming that the sample ${x_i}$ spans the whole space $mathbb{R}^d$, the value is always $nd$. Here is the proof:



        Using your notation for $X$, we know $Sigma = frac{1}{n} XX^T$ and therefore $Sigma^{-1} = n left(XX^T right)^{-1}$. Then
        $$
        x_i^T Sigma^{-1} x_i = tr(x_i^T Sigma^{-1} x_i) =
        tr(Sigma^{-1} x_i x_i^T)
        $$


        and therefore
        $$
        sum_{i = 1}^n x_i^T Sigma^{-1} x_i = tr(Sigma^{-1} sum_{i=1}^n x_i x_i^T)
        = tr(Sigma^{-1} (XX^T)) = n tr(I_d) = nd
        $$

        where $I_d$ is the $d$-dim identity matrix.







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Nov 19 '18 at 23:41









        Hans Engler

        10.1k11836




        10.1k11836






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3001665%2fwhy-is-the-number-of-non-zero-eigenvalues-equal-to-xt-sigma-1-x%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            'app-layout' is not a known element: how to share Component with different Modules

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            WPF add header to Image with URL pettitions [duplicate]