Statistical analysis framework for performing basic statistical analysis of data. The data is analysed in a single pass, when a data value is pushed to the RunningStat
or RunningRegress
objects
RunningStat
calculates for a single data set
RunningRegress
calculates for two sets of data
Procs have been provided to calculate statistics on arrays and sequences.
However, if more than a single statistical calculation is required, it is more efficient to push the data once to the RunningStat object, and call the numerous statistical procs for the RunningStat object.
var rs: RunningStat rs.push(MySeqOfData) rs.mean() rs.variance() rs.skewness() rs.kurtosis()
RunningStat = object n*: int ## number of pushed data min*, max*, sum*: float ## self-explaining mom1, mom2, mom3, mom4: float ## statistical moments, mom1 is mean
RunningRegress = object n*: int ## number of pushed data x_stats*: RunningStat ## stats for first set of data y_stats*: RunningStat ## stats for second set of data s_xy: float ## accumulated data for combined xy
proc clear(s: var RunningStat) {.raises: [], tags: [].}
proc push(s: var RunningStat; x: float) {.raises: [], tags: [].}
proc push(s: var RunningStat; x: int) {.raises: [], tags: [].}
pushes a value x for processing.
x is simply converted to float
and the other push operation is called.
proc push(s: var RunningStat; x: openArray[float | int])
pushes all values of x for processing.
Int values of x are simply converted to float
and the other push operation is called.
proc mean(s: RunningStat): float {.raises: [], tags: [].}
proc variance(s: RunningStat): float {.raises: [], tags: [].}
proc varianceS(s: RunningStat): float {.raises: [], tags: [].}
proc standardDeviation(s: RunningStat): float {.raises: [], tags: [].}
proc standardDeviationS(s: RunningStat): float {.raises: [], tags: [].}
proc skewness(s: RunningStat): float {.raises: [], tags: [].}
proc skewnessS(s: RunningStat): float {.raises: [], tags: [].}
proc kurtosis(s: RunningStat): float {.raises: [], tags: [].}
proc kurtosisS(s: RunningStat): float {.raises: [], tags: [].}
proc `+`(a, b: RunningStat): RunningStat {.raises: [], tags: [].}
combine two RunningStats.
Useful if performing parallel analysis of data series and need to re-combine parallel result sets
proc `+=`(a: var RunningStat; b: RunningStat) {.inline, raises: [], tags: [].}
proc mean[T](x: openArray[T]): float
proc variance[T](x: openArray[T]): float
proc varianceS[T](x: openArray[T]): float
proc standardDeviation[T](x: openArray[T]): float
proc standardDeviationS[T](x: openArray[T]): float
proc skewness[T](x: openArray[T]): float
proc skewnessS[T](x: openArray[T]): float
proc kurtosis[T](x: openArray[T]): float
proc kurtosisS[T](x: openArray[T]): float
proc clear(r: var RunningRegress) {.raises: [], tags: [].}
proc push(r: var RunningRegress; x, y: float) {.raises: [], tags: [].}
proc push(r: var RunningRegress; x, y: int) {.inline, raises: [], tags: [].}
pushes two values x and y for processing.
x and y are converted to float
and the other push operation is called.
proc push(r: var RunningRegress; x, y: openArray[float | int])
proc slope(r: RunningRegress): float {.raises: [], tags: [].}
proc intercept(r: RunningRegress): float {.raises: [], tags: [].}
proc correlation(r: RunningRegress): float {.raises: [], tags: [].}
proc `+`(a, b: RunningRegress): RunningRegress {.raises: [], tags: [].}
combine two RunningRegress objects.
Useful if performing parallel analysis of data series and need to re-combine parallel result sets
proc `+=`(a: var RunningRegress; b: RunningRegress) {.raises: [], tags: [].}
© 2006–2017 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/stats.html