gonum: gonum.org/v1/gonum/stat/card Index | Files

package card

import "gonum.org/v1/gonum/stat/card"

Package card provides cardinality estimation functions.

Index

Package Files

card.go doc.go hll32.go hll64.go

type HyperLogLog32 Uses

type HyperLogLog32 struct {
    // contains filtered or unexported fields
}

HyperLogLog32 is implements cardinality estimation according to the HyperLogLog algorithm described in Analysis of Algorithms, pp127–146.

func NewHyperLogLog32 Uses

func NewHyperLogLog32(prec int, h hash.Hash32) (*HyperLogLog32, error)

NewHyperLogLog32 returns a new HyperLogLog32 sketch. The value of prec must be in the range [4, 32]. NewHyperLogLog32 will allocate a byte slice that is 2^prec long.

func (*HyperLogLog32) Count Uses

func (h *HyperLogLog32) Count() float64

Count returns an estimate of the cardinality of the set of items written the receiver.

func (*HyperLogLog32) Reset Uses

func (h *HyperLogLog32) Reset()

Reset clears the receiver's registers allowing it to be reused. Reset does not alter the precision of the receiver or the hash function that is used.

func (*HyperLogLog32) SetHash Uses

func (h *HyperLogLog32) SetHash(fn hash.Hash32) error

SetHash sets the hash function of the receiver if it is nil. SetHash will return an error if it is called on a receiver with a non-nil hash function.

func (*HyperLogLog32) Union Uses

func (h *HyperLogLog32) Union(a, b *HyperLogLog32) error

Union places the union of the sketches in a and b into the receiver. Union will return an error if the precisions or hash functions of a and b do not match or if the receiver has a hash function that is set and does not match those of a and b. Hash functions provided by hash.Hash32 implementations x and y match when reflect.TypeOf(x) == reflect.TypeOf(y).

If the receiver does not have a set hash function, it can be set after a call to Union with the SetHash method.

func (*HyperLogLog32) Write Uses

func (h *HyperLogLog32) Write(b []byte) (int, error)

Write notes the data in b as a single observation into the sketch held by the receiver.

Write satisfies the io.Writer interface. If the hash.Hash32 type passed to NewHyperLogLog32 or SetHash satisfies the hash.Hash contract, Write will always return a nil error.

type HyperLogLog64 Uses

type HyperLogLog64 struct {
    // contains filtered or unexported fields
}

HyperLogLog64 is implements cardinality estimation according to the HyperLogLog algorithm described in Analysis of Algorithms, pp127–146.

func NewHyperLogLog64 Uses

func NewHyperLogLog64(prec int, h hash.Hash64) (*HyperLogLog64, error)

NewHyperLogLog64 returns a new HyperLogLog64 sketch. The value of prec must be in the range [4, 64]. NewHyperLogLog64 will allocate a byte slice that is 2^prec long.

func (*HyperLogLog64) Count Uses

func (h *HyperLogLog64) Count() float64

Count returns an estimate of the cardinality of the set of items written the receiver.

func (*HyperLogLog64) Reset Uses

func (h *HyperLogLog64) Reset()

Reset clears the receiver's registers allowing it to be reused. Reset does not alter the precision of the receiver or the hash function that is used.

func (*HyperLogLog64) SetHash Uses

func (h *HyperLogLog64) SetHash(fn hash.Hash64) error

SetHash sets the hash function of the receiver if it is nil. SetHash will return an error if it is called on a receiver with a non-nil hash function.

func (*HyperLogLog64) Union Uses

func (h *HyperLogLog64) Union(a, b *HyperLogLog64) error

Union places the union of the sketches in a and b into the receiver. Union will return an error if the precisions or hash functions of a and b do not match or if the receiver has a hash function that is set and does not match those of a and b. Hash functions provided by hash.Hash64 implementations x and y match when reflect.TypeOf(x) == reflect.TypeOf(y).

If the receiver does not have a set hash function, it can be set after a call to Union with the SetHash method.

func (*HyperLogLog64) Write Uses

func (h *HyperLogLog64) Write(b []byte) (int, error)

Write notes the data in b as a single observation into the sketch held by the receiver.

Write satisfies the io.Writer interface. If the hash.Hash64 type passed to NewHyperLogLog64 or SetHash satisfies the hash.Hash contract, Write will always return a nil error.

Package card imports 5 packages (graph). Updated 2019-11-25. Refresh now. Tools for package owners.