r - `r`中包`infotheo`的函数`entropy`
问题描述
entropy
package函数infotheo
以数据集为输入,根据熵估计方法计算熵。例如:
data(USArrests)
H <- entropy(discretize(USArrests),method="shrink")
对于 H,返回值 3.433987。但在这种情况下data(USArrests)
由 4 列(变量)组成,因此我认为它不是熵(通常指单个变量)而是联合熵。包文档中没有解释。我试图检查函数的内容,entropy
但我得到:
> infotheo::entropy
function (X, method = "emp")
{
X <- data.frame(X)
X <- data.matrix(X)
n <- NCOL(X)
N <- NROW(X)
Z <- na.omit(X)
if (!(all(Z == round(Z))))
stop("This method requires discrete values")
res <- NULL
if (method == "emp")
choi <- 0
else if (method == "mm")
choi <- 1
else if (method == "sg")
choi <- 2
else if (method == "shrink")
choi <- 3
else stop("unknown method")
res <- .Call("entropyR", X, N, n, choi, PACKAGE = "infotheo")
res
}
<bytecode: 0x000000000ae40c50>
<environment: namespace:infotheo>
从这段代码中,我无法理解结果 H 是如何计算的。
解决方案
推荐阅读
- go - 如何在运行器位于文件夹/模块中的 Heroku 中部署 Go 应用程序?
- c# - 如何在 C# 按钮内定义图标和描述的对齐方式?
- android - 在没有三星云帐户的情况下迁移三星健康数据
- c# - XmlElement 读取为不区分大小写的 C#
- php - 像素化图像,用 PHP 从中挑选可打印的(Pantone)颜色?
- c# - ASP.NET MVC(C#) 中的异步并行 Web 请求
- azure-devops - ADS 2019 - 如何在构建作业之间传递变量
- angular - Angular 如何使 mde popover 在元素旁边而不是在上方或下方生成
- c - 未链接到 libc 的应用程序的覆盖构建
- php - 网络服务器的基本布局是什么?