Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bytes ¶
type Bytes struct {
// contains filtered or unexported fields
}
Bytes is an estimator for an arbitrary value that is sampled from byte blocks.
Consider a stream of data which is divided into blocks of varying size. We want to estimate a value (like compression ratio) based on the values from recent blocks.
Bytes implements a per-byte exponential moving average (EWMA) estimator: let pos_i and val_i be the position and value of each byte for which we have data; the estimate at position p is the weighted sum:
Sum_i val_i*(1-alpha)^(p-pos_i)
-------------------------------
Sum_i (1-alpha)^(p-pos_i)
func (*Bytes) Estimate ¶
Estimate returns the current estimate of the value, based on the recent SampledBlock() calls. Returns NaN if no blocks have been sampled yet.
func (*Bytes) Init ¶
Init the estimator such that a block sampled <half-life> bytes ago has half the weight compared to a block sampled now.
Intuitively, half of the estimate comes from the values within the half-life window; and 75% of the estimate comes from values within 2x half-life.
func (*Bytes) NoSample ¶
NoSample informs the estimator that a block of the given length was not sampled.
func (*Bytes) SampledBlock ¶
SampledBlock informs the estimator that a block of the given length was sampled.