本文整理汇总了Java中org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic.copy方法的典型用法代码示例。如果您正苦于以下问题:Java StorelessUnivariateStatistic.copy方法的具体用法?Java StorelessUnivariateStatistic.copy怎么用?Java StorelessUnivariateStatistic.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic
的用法示例。
在下文中一共展示了StorelessUnivariateStatistic.copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testCopyConsistencyWithInitialMostElements
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入方法依赖的package包/类
/**
* Verifies that copied statistics remain equal to originals when
* incremented the same way by making the copy after a majority of elements
* are incremented
*/
@Test
public void testCopyConsistencyWithInitialMostElements() {
StorelessUnivariateStatistic master =
(StorelessUnivariateStatistic) getUnivariateStatistic();
StorelessUnivariateStatistic replica = null;
// select a portion of testArray till 75 % of the length to load first
long index = FastMath.round(0.75 * testArray.length);
// Put first half in master and copy master to replica
master.incrementAll(testArray, 0, (int) index);
replica = master.copy();
// Check same
Assert.assertTrue(replica.equals(master));
Assert.assertTrue(master.equals(replica));
// Now add second part to both and check again
master.incrementAll(testArray, (int) index,
(int) (testArray.length - index));
replica.incrementAll(testArray, (int) index,
(int) (testArray.length - index));
Assert.assertTrue(replica.equals(master));
Assert.assertTrue(master.equals(replica));
}
示例2: testCopyConsistencyWithInitialFirstFewElements
import org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic; //导入方法依赖的package包/类
/**
* Verifies that copied statistics remain equal to originals when
* incremented the same way by way of copying original after just a few
* elements are incremented
*/
@Test
public void testCopyConsistencyWithInitialFirstFewElements() {
StorelessUnivariateStatistic master =
(StorelessUnivariateStatistic) getUnivariateStatistic();
StorelessUnivariateStatistic replica = null;
// select a portion of testArray which is 10% of the length to load
// first
long index = FastMath.round(0.1 * testArray.length);
// Put first half in master and copy master to replica
master.incrementAll(testArray, 0, (int) index);
replica = master.copy();
// Check same
Assert.assertTrue(replica.equals(master));
Assert.assertTrue(master.equals(replica));
// Now add second part to both and check again
master.incrementAll(testArray, (int) index,
(int) (testArray.length - index));
replica.incrementAll(testArray, (int) index,
(int) (testArray.length - index));
Assert.assertTrue(master.equals(master));
Assert.assertTrue(replica.equals(replica));
Assert.assertTrue(replica.equals(master));
Assert.assertTrue(master.equals(replica));
}