common

package
v0.0.0-...-a552c4f Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClampedRandomWalkDistribution

type ClampedRandomWalkDistribution struct {
	Step Distribution
	Min  float64
	Max  float64

	State float64 // optional
}

ClampedRandomWalkDistribution is a stateful random walk, with minimum and maximum bounds. Initialize it with a Min, Max, and an underlying distribution, which is used to compute the new step value.

func CWD

func CWD(step Distribution, min, max, state float64) *ClampedRandomWalkDistribution

CWD returns a new ClampedRandomWalkDistribution based on a given distribution and optional starting state

func (*ClampedRandomWalkDistribution) Advance

func (d *ClampedRandomWalkDistribution) Advance()

Advance computes the next value of this distribution and stores it.

func (*ClampedRandomWalkDistribution) Get

Get returns the last computed value for this distribution.

type ConstantDistribution

type ConstantDistribution struct {
	State float64
}

ConstantDistribution is a stateful distribution that always returns the same value

func (*ConstantDistribution) Advance

func (d *ConstantDistribution) Advance()

Advance does nothing in a constant distribution

func (*ConstantDistribution) Get

func (d *ConstantDistribution) Get() float64

Get returns the last computed value for this distribution.

type Distribution

type Distribution interface {
	Advance()
	Get() float64 // should be idempotent
}

Distribution provides an interface to model a statistical distribution.

type MonotonicRandomWalkDistribution

type MonotonicRandomWalkDistribution struct {
	Step  Distribution
	State float64
}

MonotonicRandomWalkDistribution is a stateful random walk that only increases. Initialize it with a Start and an underlying distribution, which is used to compute the new step value. The sign of any value of the u.d. is always made positive.

func MWD

MWD creates a new MonotonicRandomWalkDistribution with a given distribution and initial state

func (*MonotonicRandomWalkDistribution) Advance

func (d *MonotonicRandomWalkDistribution) Advance()

Advance computes the next value of this distribution and stores it.

func (*MonotonicRandomWalkDistribution) Get

Get returns the last computed value for this distribution.

type NormalDistribution

type NormalDistribution struct {
	Mean   float64
	StdDev float64
	// contains filtered or unexported fields
}

NormalDistribution models a normal distribution (stateless).

func ND

func ND(mean, stddev float64) *NormalDistribution

ND creates a new normal distribution with the given mean/stddev

func (*NormalDistribution) Advance

func (d *NormalDistribution) Advance()

Advance advances this distribution. Since the distribution is stateless, this just overwrites the internal cache value.

func (*NormalDistribution) Get

func (d *NormalDistribution) Get() float64

Get returns the last computed value for this distribution.

type RandomWalkDistribution

type RandomWalkDistribution struct {
	Step Distribution

	State float64 // optional
}

RandomWalkDistribution is a stateful random walk. Initialize it with an underlying distribution, which is used to compute the new step value.

func WD

WD creates a new RandomWalkDistribution based on a given distribution and starting state

func (*RandomWalkDistribution) Advance

func (d *RandomWalkDistribution) Advance()

Advance computes the next value of this distribution and stores it.

func (*RandomWalkDistribution) Get

Get returns the last computed value for this distribution.

type SimulatedMeasurement

type SimulatedMeasurement interface {
	Tick(time.Duration)
	ToPoint(*serialize.Point)
}

SimulatedMeasurement simulates one measurement (e.g. Redis for DevOps).

type Simulator

type Simulator interface {
	Finished() bool
	Next(*serialize.Point) bool
	Fields() map[string][][]byte
	TagKeys() [][]byte
}

Simulator simulates a use case.

type SimulatorConfig

type SimulatorConfig interface {
	NewSimulator(time.Duration, uint64) Simulator
}

SimulatorConfig is an interface to create a Simulator from a time.Duration

type UniformDistribution

type UniformDistribution struct {
	Low  float64
	High float64
	// contains filtered or unexported fields
}

UniformDistribution models a uniform distribution (stateless).

func UD

func UD(low, high float64) *UniformDistribution

UD creates a new uniform distribution with the given range

func (*UniformDistribution) Advance

func (d *UniformDistribution) Advance()

Advance advances this distribution. Since the distribution is stateless, this just overwrites the internal cache value.

func (*UniformDistribution) Get

func (d *UniformDistribution) Get() float64

Get returns the last computed value for this distribution.

Jump to

Keyboard shortcuts

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