refactoring

This commit is contained in:
mrFendel 2023-04-13 03:47:36 +03:00
parent a68ebef26d
commit 0ce1861ab4

View File

@ -5,7 +5,6 @@
package space.kscience.kmath.series package space.kscience.kmath.series
import space.kscience.kmath.distributions.NormalDistribution
import space.kscience.kmath.operations.DoubleBufferOps.Companion.map import space.kscience.kmath.operations.DoubleBufferOps.Companion.map
import space.kscience.kmath.operations.DoubleField.pow import space.kscience.kmath.operations.DoubleField.pow
import space.kscience.kmath.operations.algebra import space.kscience.kmath.operations.algebra
@ -18,6 +17,12 @@ public data class VarianceRatioTestResult(val varianceRatio: Double, val zScore:
public fun varianceRatioTest(series: Series<Double>, shift: Int, homoscedastic: Boolean): VarianceRatioTestResult { public fun varianceRatioTest(series: Series<Double>, 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 sum = { x: Double, y: Double -> x + y }
val mean = series.fold(0.0, sum) / series.size val mean = series.fold(0.0, sum) / series.size