counter

package module
v0.0.0-...-1da58f9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2017 License: MIT Imports: 2 Imported by: 0

README

counter

Build Status GoDoc

A frequency counter similar to Python's collections.Counter with additional support of discrete probabilities and entropy.

See Documentation.

Documentation

Index

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 NewCounter

func NewCounter() *Counter

Create a new Counter object.

func (*Counter) Apply

func (c *Counter) Apply(fn func(interface{}) error) error

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) Copy

func (c *Counter) Copy() *Counter

Copy returns a copy of the counter

func (*Counter) Difference

func (c *Counter) Difference(d *Counter) *Counter

Difference returns a of the elements exclusively in c.

func (*Counter) Entropy

func (c *Counter) Entropy() float64

Entropy computes the entropy of the collection counted.

func (*Counter) Freqs

func (c *Counter) Freqs() ([]interface{}, []int)

Freqs returns a slice of elements and a slice of corresponding integer frequencies.

func (*Counter) Has

func (c *Counter) Has(elem interface{}) bool

Has checks whether the elem has been counted before.

func (*Counter) Intersect

func (c *Counter) Intersect(d *Counter) *Counter

Intersect return a counter of the intersection of two counter

func (*Counter) Probs

func (c *Counter) Probs() ([]interface{}, []float64)

Probs returns a slice of elements and a slice of corresponding discrete probabilities.

func (*Counter) Total

func (c *Counter) Total() int

Total returns the total number of elements counted.

func (*Counter) Union

func (c *Counter) Union(d *Counter) *Counter

Union returns a new counter that is the union of both counters.

func (*Counter) Unique

func (c *Counter) Unique() int

Unique returns the number of unique elements counted.

func (*Counter) UniqueItems

func (c *Counter) UniqueItems() []interface{}

Items returns the slice of unique items counted

func (*Counter) Update

func (c *Counter) Update(elem interface{})

Update add a new element to the counter.

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 NewPairCounter

func NewPairCounter() *PairCounter

Create a new PairCounter object.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL