Documentation ¶
Overview ¶
Package joint provides a library of data structures/algorithms for calculating online joint distribution statistics from a stream of data.
Index ¶
- func Init(wrapper CoreWrapper) error
- type Autocorr
- type Autocov
- type Core
- func (c *Core) Clear()
- func (c *Core) Count() int
- func (c *Core) Lock()
- func (c *Core) Mean(i int) (float64, error)
- func (c *Core) Push(xs ...float64) error
- func (c *Core) RLock()
- func (c *Core) RUnlock()
- func (c *Core) Sum(xs ...int) (float64, error)
- func (c *Core) Unlock()
- func (c *Core) UnsafeClear()
- func (c *Core) UnsafeCount() int
- func (c *Core) UnsafeMean(i int) (float64, error)
- func (c *Core) UnsafePush(xs ...float64) error
- func (c *Core) UnsafeSum(xs ...int) (float64, error)
- type CoreConfig
- type CoreWrapper
- type Corr
- type Cov
- type EWMCorr
- type EWMCov
- type Metric
- type SumsConfig
- type Tuple
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 Autocorr ¶
type Autocorr struct {
// contains filtered or unexported fields
}
Autocorr is a metric that tracks the sample autocorrelation. It does not satisfy the JointMetric interface, but rather the univariate Metric interface (SimpleMetric in particular), since it only tracks a single variable.
func NewAutocorr ¶
NewAutocorr instantiates an Autocorr struct.
func NewGlobalAutocorr ¶
NewGlobalAutocorr instantiates a global Autocorr struct. This is equivalent to calling NewAutocorr(lag, 0).
func (*Autocorr) Config ¶
func (a *Autocorr) Config() *CoreConfig
Config returns the CoreConfig needed.
func (*Autocorr) Push ¶
Push adds a new value for Autocorr to consume. Autocorr only takes one value, because we're calculating the lagged correlation of a series of data against itself.
type Autocov ¶
type Autocov struct {
// contains filtered or unexported fields
}
Autocov is a metric that tracks the sample autocovariance. It does not satisfy the JointMetric interface, but rather the univariate Metric interface (SimpleMetric in particular), since it only tracks a single variable.
func NewAutocov ¶
NewAutocov instantiates an Autocov struct.
func NewGlobalAutocov ¶
NewGlobalAutocov instantiates a global Autocov struct. This is equivalent to calling NewAutocov(lag, 0).
func (*Autocov) Config ¶
func (a *Autocov) Config() *CoreConfig
Config returns the CoreConfig needed.
func (*Autocov) Push ¶
Push adds a new value for Autocov to consume. Autocov only takes one value, because we're calculating the lagged covelation of a series of data against itself.
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core is a struct that stores fundamental information for multivariate 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 joint centralized sum of values seen for a provided exponent Tuple. In other words, for a Tuple m = (m_1, ..., m_k), this returns the sum of (x_i1 - μ_1)^m_1 * ... * (x_ik - μ_k)^m_k over all joint data points (x_i1, ..., x_ik).
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 for a given variable, 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, and must track > 1 variables Window *int // must be 0 if decay is set, must be nonnegative in general Vars *int // must be inferrable from Sums if not set; otherwise must be > 1 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 Corr ¶
type Corr struct {
// contains filtered or unexported fields
}
Corr is a metric that tracks the sample Pearson correlation coefficient.
func NewGlobalCorr ¶
func NewGlobalCorr() *Corr
NewGlobalCorr instantiates a global Corr struct. This is equivalent to calling NewCorr(0).
type Cov ¶
type Cov struct {
// contains filtered or unexported fields
}
Cov is a metric that tracks the sample covariance.
func NewGlobalCov ¶
func NewGlobalCov() *Cov
NewGlobalCov instantiates a global Cov struct. This is equivalent to calling NewCov(0).
type EWMCorr ¶
type EWMCorr struct {
// contains filtered or unexported fields
}
EWMCorr is a metric that tracks the sample Pearson correlation coefficient.
func (*EWMCorr) Config ¶
func (corr *EWMCorr) Config() *CoreConfig
Config returns the CoreConfig needed.
type EWMCov ¶
type EWMCov struct {
// contains filtered or unexported fields
}
EWMCov is a metric that tracks the sample exponentially weighted covariance.
func (*EWMCov) Config ¶
func (cov *EWMCov) Config() *CoreConfig
Config returns the CoreConfig needed.
type Metric ¶
type Metric interface { stream.SimpleJointMetric CoreWrapper }
Metric is the interface for a metric that tracks joint statistics 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 SumsConfig ¶
type SumsConfig []Tuple
SumsConfig is an alias for a slice of Tuples; this configures the multinomial sums that a Core object will track.