//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** @author John Miller * @version 1.6 * @date Tue Jun 16 14:34:55 EDT 2020 * @see LICENSE (MIT style license file). * * @title Model Framework: Basic Statistics */ package scalation.analytics package forecaster import scalation.linalgebra.{VectoD, VectorD} import scalation.stat.Statistic import scalation.stat.vectorD2StatVector //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** The `Stats` case class is used to hold basic statistical information: * mean, variance, auto-covariance, and auto-correlation. * Note gamma0 (biased) does not equal the sample variance (unbiased) * @param y_ the response vector (time-series data) for the training/full dataset * @param lags the maximum number of lags */ case class Stats (y_ : VectoD, lags: Int) { private val y = if (y_.isInstanceOf [VectorD]) y_.asInstanceOf [VectorD] else y_.toDense val mu = y.mean // sample mean val sig2 = y.variance // sample variance val acv = new VectorD (lags + 1) // auto-covariance vector for (k <- acv.range) acv(k) = y acov k // k-th lag auto-covariance val acr = acv / acv(0) // auto-correlation function //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** Convert a `Stats` object to a string. */ override def toString: String = { s"Stats (m = ${y.dim}, mu = $mu, sig2 = $sig2, acr = $acr)" // , acv = $acv)" } // toString } // Stats class