stats

package
v0.0.0-...-fa121f2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2017 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mul

func Mul(s1, s2 CodeStats) float64

Mul does vector multiplication of each byte frequencies of two stats.

Types

type CodeStats

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

CodeStats represents frequencies of bytes.

func English

func English() CodeStats

English returns known stats for an english text.

func New

func New(buf []byte) CodeStats

New creates new zero code stats with buffer provided.

Buffer is used for reading from reader later. We allow to provide buffer to avoid repeatable allocations since stats are recalculated frequently.

func (CodeStats) D

func (s CodeStats) D() float64

D returns square of dispersion of each byte frequencies in stats.

func (*CodeStats) ReadFrom

func (s *CodeStats) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom implements io.ReadFrom interface. It read all bytes from the reader until EOF and increments these bytes counts.

func (*CodeStats) Reset

func (s *CodeStats) Reset()

Reset resets all counts to 0.

func (*CodeStats) Write

func (s *CodeStats) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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