本文介绍了如何获得椭圆的半轴长度?在R的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有这组x和y坐标: x y as.matrix(cbind(x,y)) - > d 我想计算包含这组点的椭球,我使用函数 ellipsoidhull() $ b > $ c $在包集群中,我得到:椭圆体(d)'椭圆体'2维:` center =(2.00108 0.36696);平方ave.radius d ^ 2 = 2` 和形状矩阵= x 0.66590 0.233106 $ b $ 0.23311 0.095482 因此,面积= 0.60406 然而,从这些结果我可以得出这个椭圆的半长轴的长度并不明显。 有什么想法? 非常感谢您提前。 Tina 。 解决方案半轴的平方是形状矩阵的特征值,乘以平均半径的平方 pre $ x y< - c( 0.3130147,0.4739707,0.2000000,0.8000000,0.1000000)d library(cluster)r plot(x, y,asp = 1,xlim = c(0,4)) lines(predict(r))e a< - sqrt(r $ d2)* e [1]#半长轴b theta lines(r $ loc [1] + a * cos(theta),r $ loc [2] + a * sin(theta)) lines(r $ loc [1] + b * cos(theta),r $ loc [2] + b * sin(theta)) I have this set of x and y coordinates:x<-c(1.798805,2.402390,2.000000,3.000000,1.000000)y<-c(0.3130147,0.4739707,0.2000000,0.8000000,0.1000000)as.matrix(cbind(x,y))->dand I want to calculate the ellipsoid that contains this set of points, I use the function ellipsoidhull() in the package "cluster", and I get:> ellipsoidhull(d)'ellipsoid' in 2 dimensions:` center = ( 2.00108 0.36696 ); squared ave.radius d^2 = 2`and shape matrix =x 0.66590 0.233106y 0.23311 0.095482 hence, area = 0.60406However it's not obvious to me how I can get from these results, the lengths of the semi-major axes of this ellipse.Any idea?Thank you very much in advance.Tina. 解决方案 The square of the semi-axes are theeigenvalues of the shape matrix, times the average squared radius.x <- c(1.798805,2.402390,2.000000,3.000000,1.000000)y <- c(0.3130147,0.4739707,0.2000000,0.8000000,0.1000000)d <- cbind( x, y )library(cluster)r <- ellipsoidhull(d)plot( x, y, asp=1, xlim=c(0,4) )lines( predict(r) )e <- sqrt(eigen(r$cov)$values)a <- sqrt(r$d2) * e[1] # semi-major axisb <- sqrt(r$d2) * e[2] # semi-minor axistheta <- seq(0, 2*pi, length=200)lines( r$loc[1] + a * cos(theta), r$loc[2] + a * sin(theta) )lines( r$loc[1] + b * cos(theta), r$loc[2] + b * sin(theta) ) 这篇关于如何获得椭圆的半轴长度?在R的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-05 07:26