Documentation ¶
Overview ¶
Package runningstat implements Knuth and Welford's method for computing the standard deviation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var GqlSnapshotType = graphql.NewObject(graphql.ObjectConfig{ Name: "RunningStatSnapshot", Fields: gqlserver.BindFields[Snapshot](nil), })
GqlSnapshotType is the GraphQL type for Snapshot.
Functions ¶
This section is empty.
Types ¶
type IntStat ¶
type IntStat C.RunningStatI
func IntFromPtr ¶
IntFromPtr converts *C.RunningStatI to IntStat.
type RunningStat ¶
type RunningStat C.RunningStat
RunningStat collects statistics and allows computing mean and variance. Algorithm comes from https://www.johndcook.com/blog/standard_deviation/ .
func FromPtr ¶
func FromPtr(ptr unsafe.Pointer) (s *RunningStat)
FromPtr converts *C.RunningStat to RunningStat.
func (*RunningStat) Init ¶
func (s *RunningStat) Init(sampleInterval int)
Init initializes the instance and clears existing data. sampleInterval: how often to collect sample, will be adjusted to nearest power of two and truncated between 1 and 2^30.
func (*RunningStat) Read ¶
func (s *RunningStat) Read() Snapshot
Read returns current counters as Snapshot.
type Snapshot ¶
type Snapshot struct { Count uint64 `json:"count" gqldesc:"Number of input values."` Len uint64 `json:"len" gqldesc:"Number of collected samples."` Mean float64 `json:"mean" gqldesc:"Mean value. Valid if count>0."` Variance float64 `json:"variance" gqldesc:"Variance of samples. Valid if count>1."` Stdev float64 `json:"stdev" gqldesc:"Standard deviation of samples. Valid if count>1."` M1 float64 `json:"m1"` M2 float64 `json:"m2"` Min *uint64 `json:"min" gqldesc:"Minimum value. Valid if count>0."` Max *uint64 `json:"max" gqldesc:"Maximum value. Valid if count>0."` }
Snapshot contains a snapshot of RunningStat reading.