Hi, everyone! I have a matrix X(n*p) which is n samples from a p-dimensional normal distribution. Now I want to make the ellipsoid containing (1-?)% of the probability in the distribution based on Mahalanobis distance: ?:(x-?)'?^(-1)(x-?)??2p(?) where x and ? is the mean and variance-covariance matrix of X. Are there some functions in R which can plot the ellipsoid and calculate the volume (area for p=2, hypervolume for p>3) of the ellipsoid? I only find the "ellipsoidhull" function in "cluster" package, but it deal with ellipsoid hull containing X, which obvious not the one I want. After that, a more difficult is the following. If we have a series of matrix X1, X2, X3,? Xm which follow different p-dimensional normal distributions. And we make m ellipsoids (E1, E2, ? Em) for each matrix like the before. How can we calculate the volume of union of the m ellipsoids? One possible solution for this problem is the inclusion-exclusion principle: V(?Ei)(1?i?m)= V(Ei)(1?i?m)-?V(Ei?Ej)(1?i<j?m)+?V(Ei?Ej?Ek)(1?i<j<k?m)+(-1)^(m-1)V(E1???Em) But the problem is how to calculate the volume of intersection between 2, 3 or more ellipsoids. Are there some functions which can calculate the volume of intersection between two region or functions which directly calculate the volume of a union of two region(the region here is ellipsoid). OR yo you have any good ideas solving this problem in R? Thank you all in advance! Yuanzhi
volume of ellipsoid
7 messages · Yuanzhi Li, Carl Witthoft, yuanzhi +2 more
Well, given that an upvoted question on math.stackexchange got no answers, I'd say you're asking a very difficult question. Perhaps this paper http://www.geometrictools.com/Documentation/IntersectionOfEllipsoids.pdf will be of some help. It's possible that you could do: 1) find the ellipse of intersection of the two ellipsoids 2) find some formula for the equivalent of the "spherical cap" volume 3) apply that formula to each ellipsoid, using the intersection ellipse as the base of the caps. All this, btw, is math, not really related to R or to software programming in general. yuanzhi wrote
Hi, everyone! I have a matrix X(n*p) which is n samples from a p-dimensional normal distribution. Now I want to make the ellipsoid containing (1-?)% of the probability in the distribution based on Mahalanobis distance: ?:(x-?)'?^(-1)(x-?)??2p(?) where x and ? is the mean and variance-covariance matrix of X. Are there some functions in R which can plot the ellipsoid and calculate the volume (area for p=2, hypervolume for p>3) of the ellipsoid? I only find the "ellipsoidhull" function in "cluster" package, but it deal with ellipsoid hull containing X, which obvious not the one I want. After that, a more difficult is the following. If we have a series of matrix X1, X2, X3,? Xm which follow different p-dimensional normal distributions. And we make m ellipsoids (E1, E2, ? Em) for each matrix like the before. How can we calculate the volume of union of the m ellipsoids? One possible solution for this problem is the inclusion-exclusion principle: V(?Ei)(1?i?m)= V(Ei)(1?i?m)-?V(Ei?Ej)(1?i<j?m)+?V(Ei?Ej?Ek)(1?i<j<k?m)+(-1)^(m-1)V(E1???Em) But the problem is how to calculate the volume of intersection between 2, 3 or more ellipsoids. Are there some functions which can calculate the volume of intersection between two region or functions which directly calculate the volume of a union of two region(the region here is ellipsoid). OR yo you have any good ideas solving this problem in R? Thank you all in advance! Yuanzhi
______________________________________________ <email>R-help@
mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
-- View this message in context: http://r.789695.n4.nabble.com/volume-of-ellipsoid-tp4680409p4680435.html Sent from the R help mailing list archive at Nabble.com.
Hi, Carl Witthoft yes, it looks like a mathematical question. I will try based on your suggestion to calculate the volume of the intersection. But I still want to know whether there are some functions in R which can calculate the volume of an ellipsoid(area for p=2, hypervolume for p>3) containing X, just like the "convhulln" function in "geometry" package which can calculate the volume of convex hull containing X. -- View this message in context: http://r.789695.n4.nabble.com/volume-of-ellipsoid-tp4680409p4680445.html Sent from the R help mailing list archive at Nabble.com.
Carl Witthoft wrote
Well, given that an upvoted question on math.stackexchange got no answers, I'd say you're asking a very difficult question. Perhaps this paper http://www.geometrictools.com/Documentation/IntersectionOfEllipsoids.pdf will be of some help. It's possible that you could do: 1) find the ellipse of intersection of the two ellipsoids 2) find some formula for the equivalent of the "spherical cap" volume 3) apply that formula to each ellipsoid, using the intersection ellipse as the base of the caps. All this, btw, is math, not really related to R or to software programming in general. yuanzhi wrote
Hi, everyone! I have a matrix X(n*p) which is n samples from a p-dimensional normal distribution. Now I want to make the ellipsoid containing (1-?)% of the probability in the distribution based on Mahalanobis distance: ?:(x-?)'?^(-1)(x-?)??2p(?) where x and ? is the mean and variance-covariance matrix of X. Are there some functions in R which can plot the ellipsoid and calculate the volume (area for p=2, hypervolume for p>3) of the ellipsoid? I only find the "ellipsoidhull" function in "cluster" package, but it deal with ellipsoid hull containing X, which obvious not the one I want. After that, a more difficult is the following. If we have a series of matrix X1, X2, X3,? Xm which follow different p-dimensional normal distributions. And we make m ellipsoids (E1, E2, ? Em) for each matrix like the before. How can we calculate the volume of union of the m ellipsoids? One possible solution for this problem is the inclusion-exclusion principle: V(?Ei)(1?i?m)= V(Ei)(1?i?m)-?V(Ei?Ej)(1?i<j?m)+?V(Ei?Ej?Ek)(1?i<j<k?m)+(-1)^(m-1)V(E1???Em) But the problem is how to calculate the volume of intersection between 2, 3 or more ellipsoids. Are there some functions which can calculate the volume of intersection between two region or functions which directly calculate the volume of a union of two region(the region here is ellipsoid). OR yo you have any good ideas solving this problem in R? Thank you all in advance! Yuanzhi
______________________________________________ <email>R-help@
mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Hi, Carl Witthoft yes, it looks like a mathematical question. I will try based on your suggestion to calculate the volume of the intersection. But I still want to know whether there are some functions in R which can calculate the volume of an ellipsoid(area for p=2, hypervolume for p>3) containing X, just like the "convhulln" function in "geometry" package which can calculate the volume of convex hull containing X. thanks! -- View this message in context: http://r.789695.n4.nabble.com/volume-of-ellipsoid-tp4680409p4680446.html Sent from the R help mailing list archive at Nabble.com.
On 11/14/2013 9:35 AM, yuanzhi wrote:
Hi, Carl Witthoft yes, it looks like a mathematical question. I will try based on your suggestion to calculate the volume of the intersection. But I still want to know whether there are some functions in R which can calculate the volume of an ellipsoid(area for p=2, hypervolume for p>3) containing X, just like the "convhulln" function in "geometry" package which can calculate the volume of convex hull containing X.
See the Appendix A.2 in my paper on Elliptical Insights ... http://www.datavis.ca/papers/ellipses-STS402.pdf for the properties of ellipsoids and calculation of (hyper)volumes based on a spectral decomposition. The intersection of general ellipsoids is mathematically extremely complex. You can approximate it by acceptance sampling -- finding the proportion of random points in R^p in the bounding box of the ellipsoids which are contained in both.
Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. & Chair, Quantitative Methods York University Voice: 416 736-2100 x66249 Fax: 416 736-5814 4700 Keele Street Web: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA
On Nov 15, 2013, at 8:16 AM, Michael Friendly wrote:
On 11/14/2013 9:35 AM, yuanzhi wrote:
Hi, Carl Witthoft yes, it looks like a mathematical question. I will try based on your suggestion to calculate the volume of the intersection. But I still want to know whether there are some functions in R which can calculate the volume of an ellipsoid(area for p=2, hypervolume for p>3) containing X, just like the "convhulln" function in "geometry" package which can calculate the volume of convex hull containing X.
See the Appendix A.2 in my paper on Elliptical Insights ... http://www.datavis.ca/papers/ellipses-STS402.pdf
Thank you so much for that reference, Michael, as well as the programming supplements that you constructed and linked in that encyclopedic review.
for the properties of ellipsoids and calculation of (hyper)volumes based on a spectral decomposition.
Copying back the omitted text from the OP who probably is under the misapprehension that we are all using Nabble:
But the problem is how to calculate the volume of intersection between 2, 3 or more ellipsoids. Are there some functions which can calculate the volume of intersection between two region or functions which directly calculate the volume of a union of two region(the region here is ellipsoid). OR yo you have any good ideas solving this problem in R? Thank you all in advance!
The intersection of general ellipsoids is mathematically extremely complex. You can approximate it by acceptance sampling -- finding the proportion of random points in R^p in the bounding box of the ellipsoids which are contained in both.
So that reduces the problem to defining a function that returns TRUE for a point when it is in the interior of an ellipse. So reading your section on statistical ellipsoids, I think an intersection test for n=2 could require that the squared Mahalanobis distance from the centroids be less than the c_1^2 and c_2^2 values for the two ellipsoids under consideration.
-- Michael Friendly Email: friendly AT yorku DOT ca
David Winsemius, MD Alameda, CA, USA
2 days later
Michael Friendly wrote
On 11/14/2013 9:35 AM, yuanzhi wrote:
Hi, Carl Witthoft yes, it looks like a mathematical question. I will try based on your suggestion to calculate the volume of the intersection. But I still want to know whether there are some functions in R which can calculate the volume of an ellipsoid(area for p=2, hypervolume for p>3) containing X, just like the "convhulln" function in "geometry" package which can calculate the volume of convex hull containing X.
See the Appendix A.2 in my paper on Elliptical Insights ... http://www.datavis.ca/papers/ellipses-STS402.pdf for the properties of ellipsoids and calculation of (hyper)volumes based on a spectral decomposition. The intersection of general ellipsoids is mathematically extremely complex. You can approximate it by acceptance sampling -- finding the proportion of random points in R^p in the bounding box of the ellipsoids which are contained in both. -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. & Chair, Quantitative Methods York University Voice: 416 736-2100 x66249 Fax: 416 736-5814 4700 Keele Street Web: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA
______________________________________________
R-help@
mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Thank you for your reply. I think it is a good idea to calculate the volume in Monte-Carlo method. So the the problem change to be have to quantify whether a point is inside or outside of a region. Yes, it is easy to determine a point inside or outside a ellipsoid by seeing whether (x-x0)'?^(-1)(x-x0)-?2p(?) is greater or smaller than zero, where x0 the point we want to test. but how can we test whether a point in other shapes of region(like the bounding box(R^p) as you said or the smallest convex hull(R^p) of X)? Finally, I aslo want to know how calculate the hypervolume of the bounding box (when P>3)? Thank you again. -- View this message in context: http://r.789695.n4.nabble.com/volume-of-ellipsoid-tp4680409p4680631.html Sent from the R help mailing list archive at Nabble.com.