stats

package
v0.2.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package stats provides small streaming statistics primitives for telemetry windows, ring-buffer reductions, and UI downsampling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Summary

type Summary struct {
	Count  int
	Mean   float64
	Min    float64
	Max    float64
	StdDev float64
}

Summary is an immutable snapshot of a numeric window.

StdDev is the sample standard deviation. It is zero for a single-value window.

type Window

type Window struct {
	// contains filtered or unexported fields
}

Window accumulates streaming numeric statistics with Welford's algorithm. NaN values are ignored so downstream reducers can pass sparse streams without special casing.

func (*Window) Add

func (w *Window) Add(value float64) bool

Add folds one value into the window. It returns false when the value was not accepted, currently only for non-finite values.

func (Window) Count

func (w Window) Count() int

Count returns the number of accepted values.

func (*Window) Reset

func (w *Window) Reset()

Reset clears the accumulated window.

func (Window) Snapshot

func (w Window) Snapshot() (Summary, bool)

Snapshot returns the current summary. The boolean is false for an empty window.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL