问题标签 [apache-commons-math]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
3090 浏览

java - Apache Commons 数学优化

有人对 Apache Commmons Math 优化包有任何经验吗?更具体地说,Nelder-Mead 方法的实现?它的质量相当高吗?

0 投票
1 回答
1270 浏览

java - Why does the BigFraction class in the Apache-Commons-Math library return incorrect division results?

In the spirit of using existing, tested and stable libraries of code, I started using the Apache-Commons-Math library and its BigFraction class to perform some rational calculations for an Android app I'm writing called RationalCalc.

It works great for every task that I have thrown at it, except for one nagging problem. When dividing certain BigFraction values, I am getting incorrect results.

If I create a BigFraction with the inverse of the divisor and multiply instead, I get the same incorrect answer but perhaps that is what the library is doing internally anyway.

Does anyone know what I am doing wrong?

The division works correctly with a BigFraction of 2.5 but not 2.51, 2.49, etc...

[UPDATE]

This was indeed a bug in the apache-commons-math 2.0 libraries. The bug is fixed in v.2.1.

It is now listed in the Fixed Issues section of the bug tracker:

When multiplying two BigFraction objects with numerators larger than will fit in an java-primitive int the result of BigFraction.ZERO is incorrectly returned..

Thanks to @BartK for attempting to reproduce the issue and setting me on the right track.

[/UPDATE]

0 投票
3 回答
260 浏览

java - 获取 BigFraction 的组成部分,作为 BigInteger

将 a 的组成部分BigFraction作为 a的简单方法是BigInteger什么?

intValue基本上我想要and方法返回的结果相同,longValue但具有任意精度。

我也想避免四舍五入,所以通过 a 间接转换BigDecimal是不合适的。

0 投票
2 回答
5575 浏览

java - 使用 Apache Commons Math 确定置信区间

我有一组基准数据,我使用 Apache Math Commons 计算汇总统计数据。现在我想使用这个包来计算例如运行时间测量的算术平均值的置信区间。

这可能吗?我确信该软件包支持这一点,但是我不知道从哪里开始。

这是我在 Brent Worden 的建议下最终使用的解决方案:

0 投票
1 回答
3460 浏览

java - 如何从 Java 中的 apache commons 正确导入

首先,请原谅我糟糕的编程技巧。
我最近下载了 commons math 2.2,它带有 3 个 .jar 文件:commons-math-2.2-javadoc.jar commons-math-2.2-sources.jar commons-math-2.2.jar

我想使用正态分布方法,但我不知道如何访问它们。http://commons.apache.org/math/api-2.1/index.html

我在 mac 上使用 drJava。我需要什么 import 或 package 语句?我需要更改 drJava 首选项中的任何内容吗?任何见解将不胜感激。谢谢

0 投票
1 回答
240 浏览

math - 需要帮助了解 Apache Commons Math BracketFinder

我首先要说这感觉应该很容易......但这对我来说并不完全明显。我正在尝试使用 BrentOptimizer 来查找函数的局部最小值和最大值。我对这些的周期性有一个想法,我觉得我应该能够使用 BracketFinder 将最优值括起来,然后将其发送到 BrentOptimizer。

她是文档:http ://commons.apache.org/math/api-2.2/org/apache/commons/math/optimization/univariate/BracketFinder.html

因此,对于一个简单的情况,请考虑:

我们知道 Pi/2 有一个最大值,3Pi/2 有一个最小值。如果我从零开始并沿着函数移动,我将如何在 Pi/2 处寻找那个根?它实际上归结为构造函数参数和初始点。是否有任何最佳实践(假设您对函数的形状有所了解)可以用来以合理的方式设置这些参数?

谢谢

0 投票
1 回答
1864 浏览

java - Apache Commons 数学优化“Hello World”示例

我正在尝试实现 apache commons 数学优化包。我正在寻找一个“hello world”示例来解决两个方程的约束非线性系统。我的系统是可微分的,由两个自变量组成。apache commons 文档和彻底的 google 搜索没有产生任何代码示例供我构建——有什么建议吗?

0 投票
1 回答
4908 浏览

cluster-analysis - 如何使用距离计算 k-means++ 中的质心?

我在交互式遗传算法中使用来自 Apache Commons Math 的 k-means++ 聚类器,以减少用户评估的个体数量。

Commons Math 使其非常易于使用。用户只需要实现 Clusterable接口。它有两种方法:

double distanceFrom(T p)这很清楚 和T centroidOf(Collection<T> p),它可以让用户选择一个集群的质心。

如果在欧几里得点上使用,质心很容易计算。但在染色体上却相当困难,因为它们的含义并不总是很清楚。

我的问题:是否有一种有效的通用方法来选择质心,而不取决于问题域?(例如通过使用距离)


编辑

好的,现在这是我的质心计算代码。这个想法:与所有其他点的总距离最短的点离质心最近。

0 投票
1 回答
2549 浏览

java - Java 类中的 RealMatrix 对象

看来我不能在我的课堂上使用这个 Apache Commons Math 库,因为当我尝试在我的构造函数中使用 RealMatrix 时,我在 matrixSim 上得到了意外的标记,如下所示:

现在方法尚未实现,但是当我需要为所有 Appache 数学库方法使用 RealMatrix 数据类型时,我如何在此处使用它,而且我还需要从创建此类实例时提供的值(双数组)构造它。

0 投票
5 回答
14236 浏览

java - java - 如何在java中使用apache math 3.0为直方图生成bin?

我一直在寻找使用 apache common math 3.0 为特定数据集生成 bin(通过指定低频段、高频段和所需的 bin 数量)。我查看了频率http://commons.apache.org/math/apidocs/org/apache/commons/math3/stat/Frequency.html 但它没有给我我想要的..我想要一个给我的方法间隔中值的频率(例如:0到5之间有多少值)。有什么建议或想法吗?