程序包 org.hipparchus

类 UnitTestUtils

java.lang.Object
org.hipparchus.UnitTestUtils

public class UnitTestUtils extends Object
  • 嵌套类概要

    嵌套类
    修饰符和类型
    说明
    static class 
    Keeps track of the number of occurrences of distinct T instances added via UnitTestUtils.Frequency.addValue(Object).
    static class 
    Stripped-down version of the bivariate regression class with the same name in o.h.stat.regression.
    static class 
    Stripped down implementation of StreamingStatistics from o.h.stat.descriptive.
  • 方法概要

    修饰符和类型
    方法
    说明
    static void
    assertChiSquareAccept(double[] expected, long[] observed, double alpha)
    Asserts the null hypothesis for a ChiSquare test.
    static void
    assertChiSquareAccept(int[] values, double[] expected, long[] observed, double alpha)
    Asserts the null hypothesis for a ChiSquare test.
    static void
    assertChiSquareAccept(String[] valueLabels, double[] expected, long[] observed, double alpha)
    Asserts the null hypothesis for a ChiSquare test.
    static void
    assertContains(double[][] expected, double[] observed, double epsilon)
    verifies that for i = 0,..., observed.length, observed[i] is within epsilon of one of the values in expected[i] or observed[i] is NaN and expected[i] contains a NaN.
    static void
    assertContains(double[] values, double x, double epsilon)
    Fails iff values does not contain a number within epsilon of x.
    static void
    assertContains(String msg, double[] values, double x, double epsilon)
    Fails iff values does not contain a number within epsilon of x.
    static void
    assertContains(String msg, Complex[] values, Complex z, double epsilon)
    Fails iff values does not contain a number within epsilon of z.
    static void
    assertContains(Complex[] values, Complex z, double epsilon)
    Fails iff values does not contain a number within epsilon of z.
    static void
    assertEquals(double[] expected, double[] observed, double tolerance)
    Verifies that two double arrays have equal entries, up to tolerance
    static void
    assertEquals(double expected, double actual, double delta)
    Verifies that expected and actual are within delta, or are both NaN or infinities of the same sign.
    static void
    assertEquals(int[] expected, int[] observed)
    verifies that two int arrays are equal
    static void
    assertEquals(long[] expected, long[] observed)
    verifies that two int arrays are equal
    static void
    assertEquals(String msg, double[] expected, double[] observed, double tolerance)
    verifies that two arrays are close (sup norm)
    static void
    assertEquals(String message, double[] expected, RealVector actual, double delta)
    Asserts that all entries of the specified vectors are equal to within a positive delta.
    static void
    assertEquals(String msg, double expected, double actual, double delta)
    Verifies that expected and actual are within delta, or are both NaN or infinities of the same sign.
    static void
    assertEquals(String msg, RealMatrix expected, RealMatrix observed, double tolerance)
    verifies that two matrices are close (1-norm)
    static void
    assertEquals(String message, RealVector expected, RealVector actual, double delta)
    Asserts that all entries of the specified vectors are equal to within a positive delta.
    static void
    assertEquals(Complex expected, Complex actual, double delta)
    Verifies that real and imaginary parts of the two complex arguments differ by at most delta.
    static void
    assertEquals(FieldComplex<Binary64> expected, FieldComplex<Binary64> actual, double delta)
    Verifies that real and imaginary parts of the two complex arguments differ by at most delta.
    static void
    assertEquals(FieldMatrix<? extends FieldElement<?>> expected, FieldMatrix<? extends FieldElement<?>> observed)
    verifies that two matrices are equal
    static <T extends FieldElement<T>>
    void
    assertEquals(T[] m, T[] n)
    verifies that two arrays are equal
    static void
    assertGTest(double[] expected, long[] observed, double alpha)
    Asserts the null hypothesis that the observed counts follow the given distribution implied by expected, using a G-test
    static void
    assertGTest(RealDistribution expectedDistribution, double[] values, double alpha)
    Asserts the null hypothesis that the sample follows the given distribution, using a G-test
    static void
    assertRelativelyEquals(double expected, double actual, double relativeError)
    Verifies that the relative error in actual vs. expected is less than or equal to relativeError.
    static void
    assertRelativelyEquals(String msg, double expected, double actual, double relativeError)
    Verifies that the relative error in actual vs. expected is less than or equal to relativeError.
    static void
    assertSame(double expected, double actual)
    Verifies that the two arguments are exactly the same, either both NaN or infinities of same sign, or identical floating point values.
    static void
    assertSame(Complex expected, Complex actual)
    Verifies that real and imaginary parts of the two complex arguments are exactly the same.
    static void
    Verifies that real and imaginary parts of the two complex arguments are exactly the same.
    static void
    Verifies that serialization preserves equals and hashCode.
    static double
    chiSquare(double[] expected, long[] observed)
    Returns chi-square test statistic for expected and observed arrays.
    static double
    chiSquareTest(double[] expected, long[] observed)
    Returns p-value associated with null hypothesis that observed counts follow expected distribution.
    static double
    covariance(double[] xArray, double[] yArray)
    Computes the covariance of the two input arrays.
    static RealMatrix
    Computes a covariance matrix from a matrix whose columns represent covariates.
    static int
    eliminateZeroMassPoints(int[] densityPoints, double[] densityValues)
    Eliminates points with zero mass from densityPoints and densityValues parallel arrays.
    static double[]
    Computes the 25th, 50th and 75th percentiles of the given distribution and returns these values in an array.
    static double
    max(double[] values)
    Computes the maximum of the values in the input array.
    static double
    mean(double[] values)
    Computes the mean of the values in the array.
    static double
    median(double[] values)
    Computes the median of the values in the input array.
    static double
    min(double[] values)
     
    static Object
    Serializes an object to a bytes array and then recovers the object from the bytes array.
    static double
    standardDeviation(double[] values)
    Computes the standard deviation of the values in the input array.
    static double
    sumSquareDev(double[] values, double target)
    Computes the sum of squared deviations of from
    static void
    updateCounts(double value, long[] counts, double[] quartiles)
    Updates observed counts of values in quartiles.
    static double
    variance(double[] values)
    Computes the (bias-adjusted) variance of the values in the input array.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 方法详细资料

    • assertEquals

      public static void assertEquals(double expected, double actual, double delta)
      Verifies that expected and actual are within delta, or are both NaN or infinities of the same sign.
    • assertEquals

      public static void assertEquals(String msg, double expected, double actual, double delta)
      Verifies that expected and actual are within delta, or are both NaN or infinities of the same sign.
    • assertSame

      public static void assertSame(double expected, double actual)
      Verifies that the two arguments are exactly the same, either both NaN or infinities of same sign, or identical floating point values.
    • assertSame

      public static void assertSame(Complex expected, Complex actual)
      Verifies that real and imaginary parts of the two complex arguments are exactly the same. Also ensures that NaN / infinite components match.
    • assertEquals

      public static void assertEquals(Complex expected, Complex actual, double delta)
      Verifies that real and imaginary parts of the two complex arguments differ by at most delta. Also ensures that NaN / infinite components match.
    • assertEquals

      public static void assertEquals(FieldComplex<Binary64> expected, FieldComplex<Binary64> actual, double delta)
      Verifies that real and imaginary parts of the two complex arguments differ by at most delta. Also ensures that NaN / infinite components match.
    • assertSame

      public static void assertSame(FieldComplex<Binary64> expected, FieldComplex<Binary64> actual)
      Verifies that real and imaginary parts of the two complex arguments are exactly the same. Also ensures that NaN / infinite components match.
    • assertEquals

      public static void assertEquals(double[] expected, double[] observed, double tolerance)
      Verifies that two double arrays have equal entries, up to tolerance
    • serializeAndRecover

      public static Object serializeAndRecover(Object o)
      Serializes an object to a bytes array and then recovers the object from the bytes array. Returns the deserialized object.
      参数:
      o - 要序列化和恢复的对象
      返回:
      恢复的反序列化对象
    • checkSerializedEquality

      public static void checkSerializedEquality(Object object)
      Verifies that serialization preserves equals and hashCode. Serializes the object, then recovers it and checks equals and hash code.
      参数:
      object - 要序列化和恢复的对象
    • assertRelativelyEquals

      public static void assertRelativelyEquals(double expected, double actual, double relativeError)
      Verifies that the relative error in actual vs. expected is less than or equal to relativeError. If expected is infinite or NaN, actual must be the same (NaN or infinity of the same sign).
      参数:
      expected - 期望值
      actual - 观察值
      relativeError - 最大允许的相对误差
    • assertRelativelyEquals

      public static void assertRelativelyEquals(String msg, double expected, double actual, double relativeError)
      Verifies that the relative error in actual vs. expected is less than or equal to relativeError. If expected is infinite or NaN, actual must be the same (NaN or infinity of the same sign).
      参数:
      msg - 失败时返回的消息
      expected - 期望值
      actual - 观察值
      relativeError - 最大允许的相对误差
    • assertContains

      public static void assertContains(String msg, Complex[] values, Complex z, double epsilon)
      Fails iff values does not contain a number within epsilon of z.
      参数:
      msg - 失败时返回的消息
      values - 要搜索的复数数组
      z - 要查找的值
      epsilon - 容差
    • assertContains

      public static void assertContains(Complex[] values, Complex z, double epsilon)
      Fails iff values does not contain a number within epsilon of z.
      参数:
      values - 要搜索的复数数组
      z - 要查找的值
      epsilon - 容差
    • assertContains

      public static void assertContains(String msg, double[] values, double x, double epsilon)
      Fails iff values does not contain a number within epsilon of x.
      参数:
      msg - 失败时返回的消息
      values - 要搜索的双精度数组
      x - 要查找的值
      epsilon - 容差
    • assertContains

      public static void assertContains(double[] values, double x, double epsilon)
      Fails iff values does not contain a number within epsilon of x.
      参数:
      values - 要搜索的双精度数组
      x - 要查找的值
      epsilon - 容差
    • assertEquals

      public static void assertEquals(String message, double[] expected, RealVector actual, double delta)
      Asserts that all entries of the specified vectors are equal to within a positive delta.
      参数:
      message - 断言错误的标识消息(可以为null
      expected - 期望值
      actual - 实际值
      delta - 期望值和实际值之间的最大差异,仍然被认为相等
    • assertEquals

      public static void assertEquals(String message, RealVector expected, RealVector actual, double delta)
      断言指定向量的所有条目在正delta内相等。
      参数:
      message - 断言错误的标识消息(可以为null
      expected - 期望值
      actual - 实际值
      delta - 期望向量和实际向量之间的最大差异,在这个差异范围内两个条目仍被视为相等
    • assertEquals

      public static void assertEquals(String msg, RealMatrix expected, RealMatrix observed, double tolerance)
      验证两个矩阵是否接近(1-范数)
    • assertEquals

      public static void assertEquals(FieldMatrix<? extends FieldElement<?>> expected, FieldMatrix<? extends FieldElement<?>> observed)
      验证两个矩阵是否相等
    • assertEquals

      public static void assertEquals(String msg, double[] expected, double[] observed, double tolerance)
      验证两个数组是否接近(sup范数)
    • assertEquals

      public static void assertEquals(int[] expected, int[] observed)
      验证两个int数组是否相等
    • assertContains

      public static void assertContains(double[][] expected, double[] observed, double epsilon)
      验证对于i = 0,..., observed.length,observed[i]是否在expected[i]中的值范围内epsilon,或者observed[i]为NaN且expected[i]包含NaN。
    • assertEquals

      public static void assertEquals(long[] expected, long[] observed)
      验证两个int数组是否相等
    • assertEquals

      public static <T extends FieldElement<T>> void assertEquals(T[] m, T[] n)
      验证两个数组是否相等
    • sumSquareDev

      public static double sumSquareDev(double[] values, double target)
      计算之间的平方偏差之和
      参数:
      values - 偏差数组
      target - 计算偏差的目标值
      返回:
      平方偏差之和
    • assertChiSquareAccept

      public static void assertChiSquareAccept(String[] valueLabels, double[] expected, long[] observed, double alpha)
      对ChiSquare测试的零假设进行断言。如果零假设可以以100 * (1 - alpha)%的置信度拒绝,则失败并显示参数和测试统计数据。
      参数:
      valueLabels - 待测试的离散分布值的标签
      expected - 期望计数
      observed - 观察计数
      alpha - 测试的显著性水平
    • assertChiSquareAccept

      public static void assertChiSquareAccept(int[] values, double[] expected, long[] observed, double alpha)
      对ChiSquare测试的零假设进行断言。如果零假设可以以100 * (1 - alpha)%的置信度拒绝,则失败并显示参数和测试统计数据。
      参数:
      values - 被比较的观察和期望计数的整数值
      expected - 期望计数
      observed - 观察计数
      alpha - 测试的显著性水平
    • assertChiSquareAccept

      public static void assertChiSquareAccept(double[] expected, long[] observed, double alpha)
      对ChiSquare测试的零假设进行断言。如果零假设可以以100 * (1 - alpha)%的置信度拒绝,则失败并显示参数和测试统计数据。
      参数:
      expected - 期望计数
      observed - 观察计数
      alpha - 测试的显著性水平
    • assertGTest

      public static void assertGTest(RealDistribution expectedDistribution, double[] values, double alpha)
      断言样本遵循给定分布的零假设,使用G-测试
      参数:
      expectedDistribution - 值应该遵循的分布
      values - 样本数据
      alpha - 测试的显著性水平
    • assertGTest

      public static void assertGTest(double[] expected, long[] observed, double alpha)
      断言观察计数遵循由期望值暗示的给定分布的零假设,使用G-测试
      参数:
      expected - 期望计数
      observed - 观察计数
      alpha - 测试的显著性水平
    • getDistributionQuartiles

      public static double[] getDistributionQuartiles(RealDistribution distribution)
      计算给定分布的25th、50th和75th百分位数,并将这些值以数组形式返回。
    • updateCounts

      public static void updateCounts(double value, long[] counts, double[] quartiles)
      更新四分位数中值的观察计数。counts[0] ↔ 第一四分位数 ... counts[3] ↔ 最高四分位数
    • eliminateZeroMassPoints

      public static int eliminateZeroMassPoints(int[] densityPoints, double[] densityValues)
      从densityPoints和densityValues并行数组中消除零质量点。返回正质量点的数量,并折叠数组,使得输入数组的前 个元素表示正质量点。
    • chiSquareTest

      public static double chiSquareTest(double[] expected, long[] observed)
      返回与观察计数遵循期望分布的零假设相关的p值。如有必要,将对输入进行归一化。
      参数:
      expected - 期望计数
      observed - 观察计数
      返回:
      Chi-square测试的p值
    • chiSquare

      public static double chiSquare(double[] expected, long[] observed)
      返回期望和观察数组的卡方检验统计量。如有必要,将重新调整数组。
      参数:
      expected - 期望计数
      observed - 观察计数
      返回:
      卡方统计量
    • mean

      public static double mean(double[] values)
      计算数组中值的平均值。
      参数:
      values - 输入值
      返回:
      算术平均值
    • variance

      public static double variance(double[] values)
      计算输入数组中值的(偏差调整后)方差。
      参数:
      values - 输入值
      返回:
      偏差调整后的方差
    • standardDeviation

      public static double standardDeviation(double[] values)
      计算输入数组中值的标准差。
      参数:
      values - 输入值
      返回:
      标准差
    • median

      public static double median(double[] values)
      计算输入数组中值的中位数。
      参数:
      values - 输入值
      返回:
      估计中位数
    • covariance

      public static double covariance(double[] xArray, double[] yArray)
      计算两个输入数组的协方差。
      参数:
      xArray - 第一个协变量
      yArray - 第二个协变量
      返回:
      协方差
    • covarianceMatrix

      public static RealMatrix covarianceMatrix(RealMatrix matrix)
      从列代表协变量的矩阵计算协方差矩阵。
      参数:
      matrix - 输入矩阵
      返回:
      协方差矩阵
    • min

      public static double min(double[] values)
    • max

      public static double max(double[] values)
      计算输入数组中值的最大值。
      参数:
      values - 输入数组
      返回:
      最大值