Documentation ¶
Index ¶
- type ConcurrentCounter
- type Counter
- func (c *Counter) Apply(fn func(interface{}) error) error
- func (c *Counter) Copy() *Counter
- func (c *Counter) Difference(d *Counter) *Counter
- func (c *Counter) Entropy() float64
- func (c *Counter) Freqs() ([]interface{}, []int)
- func (c *Counter) Has(elem interface{}) bool
- func (c *Counter) Intersect(d *Counter) *Counter
- func (c *Counter) Probs() ([]interface{}, []float64)
- func (c *Counter) Total() int
- func (c *Counter) Union(d *Counter) *Counter
- func (c *Counter) Unique() int
- func (c *Counter) UniqueItems() []interface{}
- func (c *Counter) Update(elem interface{})
- type PairCounter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConcurrentCounter ¶
type ConcurrentCounter struct {
// contains filtered or unexported fields
}
ConcurrentCounter is a thread-safe version of Counter
func NewConcurrentCounter ¶
func NewConcurrentCounter() *ConcurrentCounter
func (*ConcurrentCounter) Has ¶
func (c *ConcurrentCounter) Has(elem string) bool
Has checks whether the elem has been counted before.
func (*ConcurrentCounter) Total ¶
func (c *ConcurrentCounter) Total() int
Has checks whether the elem has been counted before.
func (*ConcurrentCounter) Unique ¶
func (c *ConcurrentCounter) Unique() int
Unique returns the number of unique elements counted.
func (*ConcurrentCounter) Update ¶
func (c *ConcurrentCounter) Update(elem string)
Update add a new element to the counter.
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter for computing frequencies, discrete probabilities, and entropy over a collection of data values.
func (*Counter) Apply ¶
Apply calls the function fn on each of the unique element counted. When an error is encountered in fn, it is immediately returned.
func (*Counter) Difference ¶
Difference returns a of the elements exclusively in c.
func (*Counter) Freqs ¶
Freqs returns a slice of elements and a slice of corresponding integer frequencies.
func (*Counter) Probs ¶
Probs returns a slice of elements and a slice of corresponding discrete probabilities.
func (*Counter) UniqueItems ¶
func (c *Counter) UniqueItems() []interface{}
Items returns the slice of unique items counted
type PairCounter ¶
type PairCounter struct {
// contains filtered or unexported fields
}
PairCounter is for computing the co-occurrance frequencies, probailities and entropy of a pair of collections (i.e. two columns in a table).
func (*PairCounter) JointEntropy ¶
func (c *PairCounter) JointEntropy() float64
JointEntropy computes the joint entropy of the two collections counted.
func (*PairCounter) Total ¶
func (c *PairCounter) Total() int
Total returns the total number of pairs counted.
func (*PairCounter) Unique ¶
func (c *PairCounter) Unique() int
Unique returns the unique number of pairs counted.
func (*PairCounter) Update ¶
func (c *PairCounter) Update(elem1, elem2 interface{})
Update adds a new pair of elements to the counter, one from each collection. The order of elements in the arguments must be consistent.