【发布时间】:2021-03-03 12:48:52
【问题描述】:
我是一名数据科学家,对 Scala 还比较陌生。 我正在尝试了解 Scala 文档并从任何现有包中运行 t 检验。我正在寻找一个虚拟数据集上的示例 Scala 代码,这些代码可以工作并深入了解如何理解文档。
我正在 AWS EMR 集群环境中的 EMR Notebook(基本上是 Jupyter Notebook)中工作。我尝试参考此文档,但显然我无法理解:https://commons.apache.org/proper/commons-math/javadocs/api-3.6/org/apache/commons/math3/stat/inference/TTest.html#TTest()
这是我尝试过的,对两个具有 t-test 函数的不同包使用多个加载语句。我对 math3.state.inference 包有多行,因为我不完全确定每行之间的差异,并想确保这部分不是问题。
import org.apache.commons.math3.stat.inference
import org.apache.commons.math3.stat.inference._ // note sure if this means, import all classes/methods/functions
import org.apache.commons.math3.stat.inference.TTest._
import org.apache.commons.math3.stat.inference.TTest
import org.apache.spark.mllib.stat.test
没有错误。
import org.apache.asdf
按预期返回错误。
math3.state.inference 的文档说有一个TTest() 构造函数,然后显示了一堆方法。这如何告诉我如何使用这些函数/方法/类?我看到以下“方法”可以满足我的要求:
t(double m, double mu, double v, double n)
Computes t test statistic for 1-sample t-test.
但我不知道如何使用它。这只是我尝试过的几件事:
inference.t
inference.StudentTTest
test.student
test.TTest
TTest.t
etc.
但我收到如下错误:
An error was encountered:
<console>:42: error: object t is not a member of package org.apache.spark.mllib.stat.test
test.t
An error was encountered:
<console>:42: error: object TTest is not a member of package org.apache.spark.mllib.stat.test
test.TTest
...etc.
那么我该如何解决这些问题/在 Scala 中使用 Spark 内核计算一个简单的单样本 t 统计量?任何关于如何理解文档的说明/指导也将有助于长期发展。
【问题讨论】:
标签: scala apache-spark statistics hypothesis-test