Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Covariance matrix in barycentric coordinates

  1. Feb 3, 2012 #1
    Hi folks,

    I know the covariance matrix and the location of a point, both of which are expressed in Cartesian coordinates. I am going to represent the point in barycentric coordinates, and I would like to represent the covariance matrix for the point in barycentric coordinates as well. Does anyone have any insight into how to do transform the covariance matrix from Cartesian to barycentric coordinates?

    Thanks!
    MarkoDe
     
  2. jcsd
  3. Feb 3, 2012 #2

    Stephen Tashi

    User Avatar
    Science Advisor

    Covariance is a concept defined for random variables or samples of random variables, so I can't resist asking how you know the covariance matrix of a single point. How does this point relate to a random variable?
     
  4. Feb 3, 2012 #3

    chiro

    User Avatar
    Science Advisor

    Hey MarkoDe and welcome to the forums.

    I can't comment specifically on what you are doing and what the random variable presents but what I can say relates to random variables in general (regardless of the problem or thing they represent).

    As far as I am aware from prior work I have done, barycentric coordinates refer to a specific parametrization of a triangle with (u,v) as its coordinates.

    The cartesian model is not bounded for one and I think its important you tell us exactly what you are trying to parametrize and transform. If you are referring to a barycentric representation that is not based on a triangle, then that would be helpful.

    Anyway the standard transformation to find moments (and hence variance/covariance) of a random variable is to use the definition of expectation of a transformed variable which is basically E[f(x)] and then to use that in the context of variance/covariance.

    It will help us if you define what your random variables and what they represent to give you more specific advice.
     
  5. Feb 3, 2012 #4
    Thanks for the replies, and for encouraging me to better define my query.

    What I have:
    I have an estimate of the location of a point in three dimensionsal space, which is expressed in Cartesian coordinates. The estimate was formed using sensors with some associated noise (in this case multiple photographs from a single camera which has undergone translation and rotation.)

    I have a model for the noise in the sensor measurements. This model has allowed me to form an estimate of the covariance of the estimate of the point's location. The position estimate is in X,Y,Z, and the covariance matrix is the 3x3 matrix that expresses the uncertainty in that estimate.

    So the barycentric coordinates would require the control points to form a pyramid, since three dimensional space is being parameterized. I'm just getting into the concept of barycentric coordinates, so please forgive me if I mess up the jargon. The barycentric coordinates are to some extent arbitrary; they can be chosen to bound the estimate of the point's location, although I believe that, if it is poosible to express a point that lies outside of the pyramid, this will be useful.

    My main conceptual issue is, how do I espress my estimate for the covariance of the estimate of the point's location in the barycentric coordinates?

    I appreciate your help!
    MarkoDe
     
  6. Feb 3, 2012 #5

    chiro

    User Avatar
    Science Advisor

    MarkoDe, what you calculated the variance/mean/covariance using an existing method or by using existing data or have you just obtained those values by just 'plugging them in' or 'getting them from another source'?

    As I pointed out before, once you know how to represent the transformed random variable (example X is random variable now you have Y = f(X) which is new random variable), then you can just use E[f(X)] and other things to calculate things like variance and covariance (instead E[X]E[Y] terms you will use something like E[f(X)]E[g(Y)] terms).

    It would help if you gave us this information.
     
  7. Feb 3, 2012 #6
    Thanks for your response, chiro.

    The mean is the output of triangulation algorithms, as described earlier. An example is available in the excellent computer vision book by Hartley and Zisserman, Multiple View Geometry:
    Multiple View Geometry on Google books

    The covariance is calculated by identifying the input error sources for the triangulation algorithms, such as pixel jitter and errors in the rotation/translation, modelling them as Gaussian random variables, assigning reasonable values to them through data analysis and experimentation, calculating the Jacobian of the triangulation algorithms, and propoagating the input error sources to form an covariance estimate of the output:
    P_o = J*P_in*J^t
    Where J is the Jacobian, P_in is the covariance matrix formed from the input variables, and P_o is the output.

    Ok, this makes sense to me. How to apply it, not so much. :smile:

    Thanks again!
     
  8. Feb 4, 2012 #7

    chiro

    User Avatar
    Science Advisor

    Basically it works the same way that you would consider it work on a say a normal function.

    For example f(x) = x^2 transforms a line to a parabola. Something closer to home with your problem would involve the translation between coordinate systems. For example a transformation from (x,y) to (r,theta) is basically r = SQRT(x^2 + y^2) and theta = arctan(y/x) with appropriate modifications for appropriate quadrants.

    This is basically what you have to do. You need to find a transformation that makes sense in the context of transforming one coordinate system to another, but you are doing it for your random variables.

    I will need a little time to see how your R.V's are calculated, but basically all I would do is to apply the above idea in the context of what the R.V's represent. Once you relate the transforms from your cartesian system to your barycentric system and your R.V's in the context of your original system, then the transformation becomes a lot more intuitive.
     
  9. Feb 4, 2012 #8

    Stephen Tashi

    User Avatar
    Science Advisor

    MarkoDe,

    State the formula that you are using to convert (X,Y,Z) to barycentric coordinates.
     
  10. Feb 4, 2012 #9
    Hi Stephen and chiro.

    A point [itex]p[/itex] in Cartesian coordinates can be expressed in barycentric coordinates as:

    [itex]p=\Sigma^{4}_{i=1}\alpha_{i}c_{i}[/itex]

    where [itex]c_{i}[/itex] is one of four control points, and [itex]\alpha[/itex] is the weight for each control point.

    In this work, the following constraint is applied:

    [itex]\Sigma^{4}_{i=1}\alpha_{i}=1[/itex]

    To transform the Cartesian coordinates into barycentric coordinates:
    1. First define the Cartesian coordinates as homogeneous:

    [itex]p_{c}=\left[X\ Y\ Z\right]^{T}\rightarrow\left[X\ Y\ Z\ 1\right]^{T}[/itex]

    2. Choose the location of the four barycentric coordinates [itex]c_{i}[/itex]. This can theoretically be done arbitrarily. For this work, the barycentric coordinates are chosen so that the one of the points is at the origin of the center of mass of the points to be transformed, and the other points are 1 unit along each of the principal axes of the cartesian coordinate system. The upshot is that the locations [itex]c_{i}[/itex] are known. They, too, are defined homogeneously.

    For example, if the center of mass of the points to be transformed is at the origin, the values for [itex]c_{i}[/itex] would be:

    [itex]c_{1} = \left[1\ 0\ 0\ 1\right]^{T}[/itex]

    [itex]c_{2} = \left[0\ 1\ 0\ 1\right]^{T}[/itex]

    [itex]c_{3} = \left[0\ 0\ 1\ 1\right]^{T}[/itex]

    [itex]c_{4} = \left[0\ 0\ 0\ 1\right]^{T}[/itex]

    The matrix [itex]C[/itex] is defined where each column is one of the barycentric coordinates:

    [itex]C = \left[c_{1}\ c_{2}\ c_{3}\ c_{4}\right][/itex]

    3. For the point [itex]p[/itex], compute the values for [itex]\alpha_{i}[/itex]:

    [itex]A=\left[\alpha_{1}\ \alpha_{2}\ \alpha_{3}\ \alpha_{4}\right]^{T}[/itex]

    [itex]A=C^{-1}p[/itex]

    Which allows the Cartesian point [itex]p[/itex] to be expressed in barycentric coordinates as:

    [itex]p=CA[/itex]

    Thanks again for your help and feedback!
    MarkoDe
     
  11. Feb 4, 2012 #10

    Stephen Tashi

    User Avatar
    Science Advisor


    If read this correctly, it says that each [itex] \alpha_i [/itex] is a linear combination of the cartestian coordinates plus a constant term. So, for example, you could have something like [itex] \alpha_1 = 3.3 x - 2.6 y + 11.2 z + 7.6 [/itex]

    Is that correct? And you want to know quantities like [itex] VAR(\alpha_1) [/itex] and [itex] COV(\alpha_1, \alpha_2) [/itex] ?
     
  12. Feb 5, 2012 #11
    Stephen, your interpretation looks correct to me. And I am indeed interested in quantities like [itex] VAR(\alpha_1) [/itex] and [itex] COV(\alpha_1, \alpha_2) [/itex].

    Now that you guys have prodded me into formulating the question correctly, and you've interpreted it like that, the answer is beginning to be apparent.

    Denoting [itex]C^{-1}[/itex] as [itex]\widehat{C}[/itex], and the subscripts [itex]i,j[/itex] as the row and column indices,

    [itex] \alpha_1 = \widehat{C}_{1,1}p_{1} + \widehat{C}_{1,2}p_{2} + \widehat{C}_{1,3}p_{3} + \widehat{C}_{1,4}[/itex]

    [itex] \alpha_2 = \widehat{C}_{2,1}p_{1} + \widehat{C}_{2,2}p_{2} + \widehat{C}_{2,3}p_{3} + \widehat{C}_{2,4}[/itex]

    [itex] \alpha_3 = \widehat{C}_{3,1}p_{1} + \widehat{C}_{3,2}p_{2} + \widehat{C}_{3,3}p_{3} + \widehat{C}_{3,4}[/itex]

    [itex] \alpha_4 =\widehat{C}_{4,1}p_{1} + \widehat{C}_{4,2}p_{2} + \widehat{C}_{4,3}p_{3} + \widehat{C}_{4,4}[/itex]

    So, solving [itex] COV(\alpha_1, \alpha_2) [/itex] for example:

    [itex] COV(\alpha_1, \alpha_2) = E\left[\left(\alpha_1 - E\left[\alpha_1\right]\right)\left(\alpha_2 - E\left[\alpha_2\right]\right)\right] [/itex]

    [itex] = E\left[ \left(\widehat{C}_{1,1}p_{1} + \widehat{C}_{1,2}p_{2} + \widehat{C}_{1,3}p_{3} + \widehat{C}_{1,4} - E\left[ \widehat{C}_{1,1}p_{1} + \widehat{C}_{1,2}p_{2} + \widehat{C}_{1,3}p_{3} + \widehat{C}_{1,4}\right]\right)\left(\widehat{C}_{2,1}p_{1} + \widehat{C}_{2,2}p_{2} + \widehat{C}_{2,3}p_{3} + \widehat{C}_{2,4} - E\left[\widehat{C}_{2,1}p_{1} + \widehat{C}_{2,2}p_{2} + \widehat{C}_{2,3}p_{3} + \widehat{C}_{2,4}\right]\right)\right] [/itex]

    [itex] = E\left[ \left(\widehat{C}_{1,1}p_{1} + \widehat{C}_{1,2}p_{2} + \widehat{C}_{1,3}p_{3} + \widehat{C}_{1,4} - E\left[ \widehat{C}_{1,1}p_{1}\right] - E\left[ \widehat{C}_{1,2}p_{2}\right] - E\left[ \widehat{C}_{1,3}p_{3}\right] - E\left[ \widehat{C}_{1,4}\right]\right)\left(\widehat{C}_{2,1}p_{1} + \widehat{C}_{2,2}p_{2} + \widehat{C}_{2,3}p_{3} + \widehat{C}_{2,4} - E\left[\widehat{C}_{2,1}p_{1}\right] - E\left[ \widehat{C}_{2,2}p_{2}\right] - E\left[ \widehat{C}_{2,3}p_{3}\right] - E\left[ \widehat{C}_{2,4}\right]\right)\right] [/itex]

    [itex] = E\left[ \left(\widehat{C}_{1,1}\left(p_{1} - E\left[p_{1}\right]\right) + \widehat{C}_{1,2}\left(p_{2} - E\left[p_{2}\right]\right) + \widehat{C}_{1,3}\left(p_{3} - E\left[ p_{3}\right]\right)\right)\left(\widehat{C}_{2,1}\left(p_{1} - E\left[p_{1}\right]\right) + \widehat{C}_{2,2}\left(p_{2} - E\left[p_{2}\right]\right) + \widehat{C}_{2,3}\left(p_{3} - E\left[ p_{3}\right]\right)\right)\right] [/itex]

    [itex] = \widehat{C}_{1,1}\widehat{C}_{2,1}E\left[\left(p_{1} - E\left[p_{1}\right]\right)^{2}\right] + \widehat{C}_{1,1}\widehat{C}_{2,2}E\left[\left(p_{1} - E\left[p_{1}\right]\right)\left(p_{2} - E\left[p_{2}\right]\right)\right] + \widehat{C}_{1,1}\widehat{C}_{2,3}E\left[\left(p_{1} - E\left[p_{1}\right]\right)\left(p_{3} - E\left[p_{3}\right]\right)\right] [/itex]

    [itex]+ \widehat{C}_{1,2}\widehat{C}_{2,1}E\left[\left(p_{2} - E\left[p_{2}\right]\right)\left(p_{1} - E\left[p_{1}\right]\right)\right] + \widehat{C}_{1,2}\widehat{C}_{2,2}E\left[\left(p_{2} - E\left[p_{2}\right]\right)^{2}\right]+ \widehat{C}_{1,2}\widehat{C}_{2,3}E\left[\left(p_{2} - E\left[p_{2}\right]\right)\left(p_{3} - E\left[p_{3}\right]\right)\right][/itex]

    [itex]+ \widehat{C}_{1,3}\widehat{C}_{2,1}E\left[\left(p_{3} - E\left[p_{3}\right]\right)\left(p_{1} - E\left[p_{1}\right]\right)\right] + \widehat{C}_{1,3}\widehat{C}_{2,2}E\left[\left(p_{3} - E\left[p_{3}\right]\right)\left(p_{2} - E\left[p_{2}\right]\right)\right] + \widehat{C}_{1,3}\widehat{C}_{2,3}E\left[\left(p_{3} - E\left[p_{3}\right]\right)^{2}\right] [/itex]

    where [itex]E\left[\left(p_{1} - E\left[p_{1}\right]\right)^{2}\right][/itex], [itex]E\left[\left(p_{2} - E\left[p_{2}\right]\right)^{2}\right][/itex], [itex]E\left[\left(p_{3} - E\left[p_{3}\right]\right)^{2}\right][/itex], [itex] E\left[\left(p_{1} - E\left[p_{1}\right]\right)\left(p_{2} - E\left[p_{2}\right]\right)\right][/itex], [itex]E\left[\left(p_{1} - E\left[p_{1}\right]\right)\left(p_{3} - E\left[p_{3}\right]\right)\right][/itex], and [itex]E\left[\left(p_{2} - E\left[p_{2}\right]\right)\left(p_{3} - E\left[p_{3}\right]\right)\right] [/itex] are all known from the entries of the input covariance matrix of [itex]p[/itex],

    and the entries of [itex]C_{i,j}[/itex] are also known.

    Is there a more elegant way to express this? Writing that out for every all the combinations of [itex]\alpha[/itex]'s is pretty cumbersome.

    Thanks again for your help, and for prodding me to get this into a form where the answer was apparent!
     
  13. Feb 5, 2012 #12

    chiro

    User Avatar
    Science Advisor

    I can see a kind of 'covariance' relation with your last expression. Also when you refer to terms about (p1 - E[p1])^2, this is basically a variance term for p1.

    The best way I can think of is to change the E[(p1 - E[p1)^2] terms normal VAR(p1) terms and do the same for COV terms. Then you might have to do some kind of matrix factorization and create two matrices since i see the (2,1), (2,2), and (2,3) terms for your C-inverse matrix repeated which means they can be factorized out into a different matrix.

    Another approach would be to write your system in the normal covariance matrix format (which basically does COV(a,b) for every a and b that are random variables in your system) and based on that you can make an interpretation of what all of it actually means.
     
  14. Feb 6, 2012 #13

    Stephen Tashi

    User Avatar
    Science Advisor

    Probably, but first we should look for a more elegant way to derive the answer. I think the COV(X,Y) operation is "bi-linear", so you can use that fact instead of using expectations and the definition of covariance.
     
  15. Feb 7, 2012 #14
    I'm interested in following your intuition, Stephen, but I don't quite understand. Wikipedia's definition for 'bilinear' didn't shed any light. Would you care to comment more?
     
  16. Feb 8, 2012 #15
    I'll take a stab at simplifying.

    First, some notation:
    [itex]\widehat{c}_{i}[/itex] is the row vector from the ith row of the matrix [itex]\widehat{C} = C^{-1}[/itex]
    [itex]P_{p}[/itex] is the 3x3 covariance matrix for the mean estimate [itex]p[/itex].
    [itex]P_{\alpha}[/itex] is the 4x4 covariance matrix for the [itex]\alpha[/itex] values.
    [itex] i,j [/itex] are the row, column indices for a matrix.
    [itex] \bullet [/itex] denotes the dot product.

    Then the covariance matrix [itex]P_{\alpha}[/itex] is computed as:

    [itex]P_{\alpha,i,j}=\widehat{c}^{T}_{i}\bullet\left(P_{p} \widehat{c}^{T}_j\right)[/itex]

    Looks nifty enough that I am satisfied. However, if you guys have additional insight, or a more elegant way of expressing/solving, then I am definitely interested.

    Thanks again for your help!

    MarkoDe
     
  17. Feb 8, 2012 #16

    Stephen Tashi

    User Avatar
    Science Advisor

    Look at the Wikipedia article on Covariance. The property
    Cov(aX + bY,cW+dV) =ac Cov(X,W) + ad Cov(X,V) + bc Cov(Y,W) + bd Cov(Y,V)
    summarizes most of what you need.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Covariance matrix in barycentric coordinates
  1. Covariance Matrix (Replies: 7)

Loading...