0

I'm trying to create a 3D plot of a random draw from a Dirichlet distribution but it only seems to be plotting in 2 dimensions even though I have data for three variables.

draw <- rdirichlet(100, alpha = c(.3,.4,.3))
scatter3D(x ,y, z)
scatterplot3d(draw[,1:3])

As you can see, I tried in two ways, using two different packages. In the first, you can see in the image below that they y-values seem to be missing, but I'm not sure why. enter image description here

When I try using a different package, not only are the y-values missing, but the other two values are plotted as if they are on a 45 degree line, which is not correct. Any help is greatly appreciated! enter image description here

4

1 回答 1

2

y 值没有丢失。在您的情况下,3 阶 Dirichlet 分布将具有位于二维单纯形(即二维平面)上的点,因为每个点的坐标总和必须为 1。(维基百科页面上的 pdf 图可能会有所帮助看到这个。)

在您的第二个图中,这些点实际上并不在 45 度线上(它们只是看起来像)。包中的交互式 3d 图rgl可能有助于看到这一点。

draw <- gtools::rdirichlet(100, alpha = c(.3, .4, .3))
rgl::plot3d(draw)

一个看起来像这样的情节:

在此处输入图像描述

实际上在二维单纯形上有点,如果旋转它可以看到:

在此处输入图像描述

于 2016-10-18T01:41:07.073 回答