Documentation ¶
Overview ¶
Package moment provides a library of data structures/algorithms for calculating online moment-based statistics from a stream of data.
Index ¶
- func Init(wrapper CoreWrapper) error
- type Core
- func (c *Core) Clear()
- func (c *Core) Count() int
- func (c *Core) Lock()
- func (c *Core) Mean() (float64, error)
- func (c *Core) Push(x float64) error
- func (c *Core) RLock()
- func (c *Core) RUnlock()
- func (c *Core) Sum(k int) (float64, error)
- func (c *Core) Unlock()
- func (c *Core) UnsafeClear()
- func (c *Core) UnsafeCount() int
- func (c *Core) UnsafeMean() (float64, error)
- func (c *Core) UnsafePush(x float64) error
- func (c *Core) UnsafeSum(k int) (float64, error)
- type CoreConfig
- type CoreWrapper
- type EWMA
- type EWMMoment
- type EWMStd
- type Kurtosis
- type Mean
- type Metric
- type Moment
- type Skewness
- type Std
- type SumsConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(wrapper CoreWrapper) error
Init sets a CoreWrapper up with a core for consuming.
Types ¶
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core is a struct that stores fundamental information for moments of a stream.
func NewCore ¶
func NewCore(config *CoreConfig) (*Core, error)
NewCore instantiates a Core struct based on a provided config.
func (*Core) Sum ¶
Sum returns the kth-power centralized sum of values seen. In other words, this returns the kth power sum of the differences of the values seen from their mean.
func (*Core) UnsafeClear ¶
func (c *Core) UnsafeClear()
UnsafeClear clears all stats being tracked, but does not lock. This should only be used if the user plans to make use of the Lock()/Unlock() Core methods.
func (*Core) UnsafeCount ¶
UnsafeCount returns the number of values seen seen globally, but does not lock. This should only be used if the user plans to make use of the [R]Lock()/[R]Unlock() Core methods.
func (*Core) UnsafeMean ¶
UnsafeMean returns the mean of values seen, but does not lock. This should only be used if the user plans to make use of the [R]Lock()/[R]Unlock() Core methods.
func (*Core) UnsafePush ¶
UnsafePush adds a new value for a Core object to consume, but does not lock. This should only be used if the user plans to make use of the Lock()/Unlock() Core methods.
type CoreConfig ¶
type CoreConfig struct { Sums SumsConfig // sums tracked must be positive Window *int // must be 0 if decay is set, must be nonnegative in general Decay *float64 // optional, must lie in the interval (0, 1) }
CoreConfig is the struct containing configuration options for instantiating a Core object.
func MergeConfigs ¶
func MergeConfigs(configs ...*CoreConfig) (*CoreConfig, error)
MergeConfigs merges CoreConfig objects.
type CoreWrapper ¶
type CoreWrapper interface { SetCore(*Core) Config() *CoreConfig }
CoreWrapper is the interface for an entity that wraps around a Core for stats. The methods below are required for setting up a Core for the wrapper.
type EWMA ¶
type EWMA struct {
// contains filtered or unexported fields
}
EWMA is a metric that tracks the exponentially weighted moving average.
type EWMMoment ¶
type EWMMoment struct {
// contains filtered or unexported fields
}
EWMMoment is a metric that tracks the kth exponentially weighted sample central moment.
func NewEWMMoment ¶
NewEWMMoment instantiates a EWMMoment struct.
func (*EWMMoment) Config ¶
func (m *EWMMoment) Config() *CoreConfig
Config returns the CoreConfig needed.
type EWMStd ¶
type EWMStd struct {
// contains filtered or unexported fields
}
EWMStd is a metric that tracks the exponentially weighted sample standard deviation.
type Kurtosis ¶
type Kurtosis struct {
// contains filtered or unexported fields
}
Kurtosis is a metric that tracks the sample excess kurtosis.
func NewGlobalKurtosis ¶
func NewGlobalKurtosis() *Kurtosis
NewGlobalKurtosis instantiates a global Kurtosis struct. This is equivalent to calling NewKurtosis(0).
func NewKurtosis ¶
NewKurtosis instantiates a Kurtosis struct.
func (*Kurtosis) Config ¶
func (k *Kurtosis) Config() *CoreConfig
Config returns the CoreConfig needed.
type Mean ¶
type Mean struct {
// contains filtered or unexported fields
}
Mean is a metric that tracks the mean.
func NewGlobalMean ¶
func NewGlobalMean() *Mean
NewGlobalMean instantiates a global Mean struct. This is equivalent to calling NewMean(0).
type Metric ¶
type Metric interface { stream.SimpleMetric CoreWrapper }
Metric is the interface for a metric that tracks the moment of a stream. Any Metric that will actually be consuming values (i.e. will have its Push method called) needs to be passed into the Init() method, which sets it up with a Core for consuming values and keeping track of centralized sums.
type Moment ¶
type Moment struct {
// contains filtered or unexported fields
}
Moment is a metric that tracks the kth sample central moment.
func NewGlobal ¶
NewGlobal instantiates a global Moment struct. This is equivalent to calling New(k, 0).
type Skewness ¶
type Skewness struct {
// contains filtered or unexported fields
}
Skewness is a metric that tracks the adjusted Fisher-Pearson sample skewness.
func NewGlobalSkewness ¶
func NewGlobalSkewness() *Skewness
NewGlobalSkewness instantiates a global Skewness struct. This is equivalent to calling NewSkewness(0).
func NewSkewness ¶
NewSkewness instantiates a Skewness struct.
func (*Skewness) Config ¶
func (s *Skewness) Config() *CoreConfig
Config returns the CoreConfig needed.
type Std ¶
type Std struct {
// contains filtered or unexported fields
}
Std is a metric that tracks the sample standard deviation.
func NewGlobalStd ¶
func NewGlobalStd() *Std
NewGlobalStd instantiates a global Std struct. This is equivalent to calling NewStd(0).
type SumsConfig ¶
SumsConfig is an alias for a map of ints to bools; this configures the sums that a Core object will track.