dsp

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0, BSD-2-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Hour = time.Hour
	Day  = time.Hour * 24
	Week = Day * 7
)
View Source
var (
	// MaxAutoCorrelationPeakSearchIntervalSeconds is the maximum search interval for validating if
	// a periodicity hint is a peak of the ACF.
	MaxAutoCorrelationPeakSearchIntervalSeconds = (time.Hour * 4).Seconds()
)

Functions

func AutoCorrelation added in v0.6.0

func AutoCorrelation(samples []float64) []float64

func Debug added in v0.6.0

func Debug(predictor prediction.Interface, namer metricnaming.MetricNamer, config *config.Config) (*Signal, *Signal, *Signal, error)

func NewPrediction

func NewPrediction(realtimeProvider providers.RealTime, historyProvider providers.History, mc config.AlgorithmModelConfig) prediction.Interface

Types

type Estimator

type Estimator interface {
	GetEstimation(signal *Signal, periodLength time.Duration) *Signal
	String() string
}

func NewFFTEstimator

func NewFFTEstimator(minNumOfSpectrumItems, maxNumOfSpectrumItems int, highFrequencyThreshold, lowAmplitudeThreshold, marginFraction float64) Estimator

func NewMaxValueEstimator

func NewMaxValueEstimator(marginFraction float64) Estimator

type Signal

type Signal struct {
	// SampleRate is the sampling rate in hertz
	SampleRate float64
	// Samples store all samples
	Samples []float64
}

Signal represents a discrete signal.

func SamplesToSignal

func SamplesToSignal(samples []common.Sample, sampleInterval time.Duration) *Signal

func (*Signal) Denormalize

func (s *Signal) Denormalize(min, max float64) (*Signal, error)

Denormalize denormalizes the signal between min and max.

func (*Signal) Duration

func (s *Signal) Duration() float64

Duration returns the signal duration in seconds.

func (*Signal) Filter

func (s *Signal) Filter(threshold float64) *Signal

Filter filters out frequency components whose amplitudes are less than the threshold and returns a new signal

func (*Signal) FindPeriod added in v0.6.0

func (s *Signal) FindPeriod() time.Duration

func (*Signal) Max

func (s *Signal) Max() float64

Max returns the maximum sample value.

func (*Signal) Min

func (s *Signal) Min() float64

Min returns the minimum sample value.

func (*Signal) Normalize

func (s *Signal) Normalize() (*Signal, error)

Normalize normalizes the signal between -1 and 1 and return a new signal instance.

func (*Signal) Num

func (s *Signal) Num() int

Num returns the number of samples in the signal.

func (*Signal) Plot

func (s *Signal) Plot(color string, o ...charts.GlobalOpts) *charts.Line

func (*Signal) String

func (s *Signal) String() string

func (*Signal) Truncate

func (s *Signal) Truncate(d time.Duration) (*Signal, int)

Truncate truncates the signal to a length of multiple of d.

Jump to

Keyboard shortcuts

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