6

この x 座標と y 座標のセットがあります。

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))->d

そして、この一連の点を含む楕円体を計算したいのでellipsoidhull()、パッケージ「クラスター」の関数を使用すると、次のようになります。

> ellipsoidhull(d)
'ellipsoid' in 2 dimensions:`
 center = ( 2.00108 0.36696 ); squared ave.radius d^2 =  2`
and shape matrix =
x 0.66590 0.233106
y 0.23311 0.095482
  hence, area  =  0.60406

ただし、これらの結果から、この楕円の半長軸の長さをどのように取得できるかは明らかではありません。

何か案が?

事前にどうもありがとうございました。

ティナ。

4

2 に答える 2

5

あなたはこれを行うことができます:

exy <- predict(ellipsoidhull(d)) ## the ellipsoid boundary
me <- colMeans((exy))            ## center of the ellipse

次に、最小距離と最大距離を計算して、それぞれ短軸と長軸を取得します。

dist2center <- sqrt(rowSums((t(t(exy)-me))^2))
max(dist2center)     ## major axis
[1] 1.264351
> min(dist2center)   ## minor axis
[1] 0.1537401

EDIT 軸で楕円をプロットします。

plot(exy,type='l',asp=1)
points(d,col='blue')
points(me,col='red')
lines(rbind(me,exy[dist2center == min(dist2center),]))
lines(exy[dist2center == max(dist2center),])

ここに画像の説明を入力

于 2013-08-16T17:13:25.240 に答える
5

半軸の 2 乗は、形状行列の固有値に平均半径の 2 乗を掛けたものです。

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 axis
b <- sqrt(r$d2) * e[2]  # semi-minor axis
theta <- 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) )
于 2013-08-16T18:17:39.473 に答える