Record Class TestResult

java.lang.Object
java.lang.Record
cloud.opencode.base.math.stats.inference.TestResult
Record Components:
testName - the name of the test / 检验名称
statistic - the test statistic value / 检验统计量值
pValue - the p-value / p 值
degreesOfFreedom - the degrees of freedom (NaN if not applicable) / 自由度(不适用时为 NaN)

public record TestResult(String testName, double statistic, double pValue, double degreesOfFreedom) extends Record
Immutable record holding the result of a statistical hypothesis test. 不可变记录,保存统计假设检验的结果

Contains the test name, test statistic, p-value, and degrees of freedom. Use isSignificant(double) to check significance at a given alpha level.

包含检验名称、检验统计量、p 值和自由度。 使用 isSignificant(double) 在给定显著性水平下检查显著性。

Since:
JDK 25, opencode-base-math V1.0.3
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    TestResult(String testName, double statistic, double pValue, double degreesOfFreedom)
    Creates an instance of a TestResult record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the value of the degreesOfFreedom record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Checks whether the result is statistically significant at the default alpha = 0.05.
    boolean
    isSignificant(double alpha)
    Checks whether the result is statistically significant at the given alpha level.
    double
    Returns the value of the pValue record component.
    double
    Returns the value of the statistic record component.
    Returns the value of the testName record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • TestResult

      public TestResult(String testName, double statistic, double pValue, double degreesOfFreedom)
      Creates an instance of a TestResult record class.
      Parameters:
      testName - the value for the testName record component
      statistic - the value for the statistic record component
      pValue - the value for the pValue record component
      degreesOfFreedom - the value for the degreesOfFreedom record component
  • Method Details

    • isSignificant

      public boolean isSignificant(double alpha)
      Checks whether the result is statistically significant at the given alpha level. 检查结果在给定显著性水平下是否具有统计显著性
      Parameters:
      alpha - the significance level (e.g., 0.05) / 显著性水平(例如 0.05)
      Returns:
      true if pValue < alpha / 如果 p 值小于 alpha 则返回 true
    • isSignificant

      public boolean isSignificant()
      Checks whether the result is statistically significant at the default alpha = 0.05. 检查结果在默认显著性水平 alpha = 0.05 下是否具有统计显著性
      Returns:
      true if pValue < 0.05 / 如果 p 值小于 0.05 则返回 true
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • testName

      public String testName()
      Returns the value of the testName record component.
      Returns:
      the value of the testName record component
    • statistic

      public double statistic()
      Returns the value of the statistic record component.
      Returns:
      the value of the statistic record component
    • pValue

      public double pValue()
      Returns the value of the pValue record component.
      Returns:
      the value of the pValue record component
    • degreesOfFreedom

      public double degreesOfFreedom()
      Returns the value of the degreesOfFreedom record component.
      Returns:
      the value of the degreesOfFreedom record component