From 0ce1861ab4724912e796ffa92aa940fdaa0735a0 Mon Sep 17 00:00:00 2001 From: mrFendel Date: Thu, 13 Apr 2023 03:47:36 +0300 Subject: [PATCH] refactoring --- .../series/{VarianceRatio.kt => VarianceRatioTest.kt} | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) rename kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/{VarianceRatio.kt => VarianceRatioTest.kt} (90%) diff --git a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/VarianceRatio.kt b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/VarianceRatioTest.kt similarity index 90% rename from kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/VarianceRatio.kt rename to kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/VarianceRatioTest.kt index 2dfcd6b00..77163f638 100644 --- a/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/VarianceRatio.kt +++ b/kmath-stat/src/commonMain/kotlin/space/kscience/kmath/series/VarianceRatioTest.kt @@ -5,7 +5,6 @@ package space.kscience.kmath.series -import space.kscience.kmath.distributions.NormalDistribution import space.kscience.kmath.operations.DoubleBufferOps.Companion.map import space.kscience.kmath.operations.DoubleField.pow import space.kscience.kmath.operations.algebra @@ -18,6 +17,12 @@ public data class VarianceRatioTestResult(val varianceRatio: Double, val zScore: public fun varianceRatioTest(series: Series, shift: Int, homoscedastic: Boolean): VarianceRatioTestResult { + /** + * Calculate the Z statistic and the p-value for the Lo and MacKinlay's Variance Ratio test (1987) + * under Homoscedastic or Heteroscedstic assumptions + * https://ssrn.com/abstract=346975 + * **/ + val sum = { x: Double, y: Double -> x + y } val mean = series.fold(0.0, sum) / series.size