stego

package module
v0.0.0-...-7b09ef9 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 6 Imported by: 0

README

stego

Basic golang stats package for running distributions and analysis of sequence data.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Maxf

func Maxf(l, r float64) float64

func Minf

func Minf(l, r float64) float64

func Sumf

func Sumf(slice []float64) float64

Sumf produces a scalar representing the sum of all values in a float slice

Types

type ProbabilityDistribution

type ProbabilityDistribution struct {
	Max    float64         `json:"max"`
	Min    float64         `json:"min"`
	Mean   float64         `json:"mean"`
	Stddev float64         `json:"stddev"`
	VLen   int             `json:"v_len"`
	Values *TSMaxFloatHeap `json:"values"`
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewProbabilityDistribution

func NewProbabilityDistribution() *ProbabilityDistribution

func (*ProbabilityDistribution) Add

func (pd *ProbabilityDistribution) Add(value float64)

Add a value to the distribution

func (*ProbabilityDistribution) Clear

func (pd *ProbabilityDistribution) Clear()

func (*ProbabilityDistribution) JSON

func (pd *ProbabilityDistribution) JSON() (string, error)

JSON returns the probability distribution as a JSON string

func (*ProbabilityDistribution) Len

func (pd *ProbabilityDistribution) Len() int

type Rate

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

Rate records the rate of requests to a time distribution

func (*Rate) Increment

func (r *Rate) Increment()

func (*Rate) Last

func (r *Rate) Last(n int) int

Last calulates the rate the last n seconds. Returns -1 if the value could not be calculated. (No data or interval too short)

type TSMaxFloatHeap

type TSMaxFloatHeap struct {
	sync.RWMutex // This is public for extensiblity. Beware deadlock, though!
	// contains filtered or unexported fields
}

TSMaxFloatHeap is a thread safe max heap of floats for always-ordered data

func NewTSMaxFloatHeap

func NewTSMaxFloatHeap() *TSMaxFloatHeap

func NewTSMaxFloatHeapFromSlice

func NewTSMaxFloatHeapFromSlice(items ...interface{}) *TSMaxFloatHeap

func (*TSMaxFloatHeap) At

func (mh *TSMaxFloatHeap) At(idx int) float64

func (*TSMaxFloatHeap) Clear

func (mh *TSMaxFloatHeap) Clear()

func (*TSMaxFloatHeap) Len

func (mh *TSMaxFloatHeap) Len() int

func (*TSMaxFloatHeap) Less

func (mh *TSMaxFloatHeap) Less(i, j int) bool

func (*TSMaxFloatHeap) Pop

func (mh *TSMaxFloatHeap) Pop() interface{}

func (*TSMaxFloatHeap) Push

func (mh *TSMaxFloatHeap) Push(item interface{})

func (*TSMaxFloatHeap) PushSlice

func (mh *TSMaxFloatHeap) PushSlice(items ...interface{})

Push implements a thread-safe push operation into a probability heap

func (*TSMaxFloatHeap) Swap

func (mh *TSMaxFloatHeap) Swap(i, j int)

func (*TSMaxFloatHeap) TopN

func (mh *TSMaxFloatHeap) TopN(n int) ([]float64, error)

TopN returns the top n values from the internal list

type TimeDistribution

type TimeDistribution struct {
	KeyedRate map[string]*Rate // Maps some key to a probability distribution
	Interval  []int            // Represents a list of times, (1 second, 1 minute, 1 hour, etc)
	sync.RWMutex
}

TODO(jparr721) - Add different back ends for badger db and redis for storage. TimeDistribution keeps track of input rates over time intervals via some keyed value

func NewTimeDistribution

func NewTimeDistribution(interval []int) *TimeDistribution

func (*TimeDistribution) Clear

func (td *TimeDistribution) Clear()

Clears the time distribution keeping the interval present

func (*TimeDistribution) Increment

func (td *TimeDistribution) Increment(key string)

Jump to

Keyboard shortcuts

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