math

package
v0.0.60 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultContainedVariance = 0.99
View Source
const (
	FftFreqMetricName = "freq"
)

Variables

This section is empty.

Functions

func BatchConvexHull

func BatchConvexHull(sortOnly bool) bitflow.BatchProcessingStep

func ComputeAndProjectPCA

func ComputeAndProjectPCA(containedVariance float64) bitflow.BatchProcessingStep

func FeatureWindowAverage

func FeatureWindowAverage(stats *FeatureWindowStats) bitflow.Value

func FeatureWindowSlope

func FeatureWindowSlope(stats *FeatureWindowStats) bitflow.Value

func LoadBatchPCAModel

func LoadBatchPCAModel(filename string, containedVariance float64) (bitflow.BatchProcessingStep, error)

func LoadStreamingPCAModel

func LoadStreamingPCAModel(filename string, containedVariance float64) (bitflow.SampleProcessor, error)

func NewBatchAvgAggregator added in v0.0.56

func NewBatchAvgAggregator() bitflow.BatchProcessingStep

func NewBatchKurtosisAggregator added in v0.0.56

func NewBatchKurtosisAggregator() bitflow.BatchProcessingStep

func NewBatchMaxAggregator added in v0.0.56

func NewBatchMaxAggregator() bitflow.BatchProcessingStep

func NewBatchMinAggregator added in v0.0.56

func NewBatchMinAggregator() bitflow.BatchProcessingStep

func NewBatchMultiplyAggregator added in v0.0.56

func NewBatchMultiplyAggregator() bitflow.BatchProcessingStep

func NewBatchStddevAggregator added in v0.0.56

func NewBatchStddevAggregator() bitflow.BatchProcessingStep

func NewBatchSumAggregator added in v0.0.56

func NewBatchSumAggregator() bitflow.BatchProcessingStep

func NewBatchVarianceAggregator added in v0.0.56

func NewBatchVarianceAggregator() bitflow.BatchProcessingStep

func RegisterAggregateAvg

func RegisterAggregateAvg(b reg.ProcessorRegistry)

func RegisterAggregateSlope

func RegisterAggregateSlope(b reg.ProcessorRegistry)

func RegisterBatchAggregators added in v0.0.56

func RegisterBatchAggregators(b reg.ProcessorRegistry)

func RegisterBatchFeatureStatsAggregators added in v0.0.56

func RegisterBatchFeatureStatsAggregators(b reg.ProcessorRegistry)

func RegisterConvexHull

func RegisterConvexHull(b reg.ProcessorRegistry)

func RegisterConvexHullSort

func RegisterConvexHullSort(b reg.ProcessorRegistry)

func RegisterFFT

func RegisterFFT(b reg.ProcessorRegistry)

func RegisterMinMaxScaling

func RegisterMinMaxScaling(b reg.ProcessorRegistry)

func RegisterPCA

func RegisterPCA(b reg.ProcessorRegistry)

func RegisterPCALoad

func RegisterPCALoad(b reg.ProcessorRegistry)

func RegisterPCALoadStream

func RegisterPCALoadStream(b reg.ProcessorRegistry)

func RegisterPCAStore

func RegisterPCAStore(b reg.ProcessorRegistry)

func RegisterRMS

func RegisterRMS(b reg.ProcessorRegistry)

func RegisterSphere

func RegisterSphere(b reg.ProcessorRegistry)

func RegisterStandardizationScaling

func RegisterStandardizationScaling(b reg.ProcessorRegistry)

func SamplesToMatrix

func SamplesToMatrix(samples []*bitflow.Sample) mat.Matrix

func StorePCAModel

func StorePCAModel(filename string) bitflow.BatchProcessingStep

Types

type AngleBasedSort

type AngleBasedSort struct {
	Reference Point
	Points    []Point
}

func (AngleBasedSort) Len

func (s AngleBasedSort) Len() int

func (AngleBasedSort) Less

func (s AngleBasedSort) Less(i, j int) bool

func (AngleBasedSort) Swap

func (s AngleBasedSort) Swap(i, j int)

type BatchAggregateFunc added in v0.0.56

type BatchAggregateFunc func(aggregated bitflow.Value, newValue bitflow.Value) bitflow.Value

type BatchAggregator added in v0.0.43

type BatchAggregator struct {
	Aggregator  BatchAggregateFunc
	Description string
}

func (*BatchAggregator) ProcessBatch added in v0.0.43

func (a *BatchAggregator) ProcessBatch(header *bitflow.Header, samples []*bitflow.Sample) (*bitflow.Header, []*bitflow.Sample, error)

func (*BatchAggregator) String added in v0.0.43

func (a *BatchAggregator) String() string

type BatchFeatureStatsAggregator added in v0.0.56

type BatchFeatureStatsAggregator struct {
	Aggregate   GetFeatureFunc
	Description string
}

func (*BatchFeatureStatsAggregator) ProcessBatch added in v0.0.56

func (ba *BatchFeatureStatsAggregator) ProcessBatch(header *bitflow.Header, samples []*bitflow.Sample) (*bitflow.Header, []*bitflow.Sample, error)

func (*BatchFeatureStatsAggregator) String added in v0.0.56

func (ba *BatchFeatureStatsAggregator) String() string

type BatchFft

type BatchFft struct {
	// By default, the upper half of the FFT results is cut off, because the FFT results are symmetric.
	// Set LeaveSymmetricPart to true to include preserve all result values.
	LeaveSymmetricPart bool

	// By default, the FFT results are normalized. Set SkipNormalization to true to avoid this.
	// Normalization helps comparing the results of FFTs with different numbers of input values.
	// Normalization is done by dividing every FFT result value by the total number of input values to the FFT.
	// If FillZeros=true, this is the closest power of two above the number of actual input samples. If FillZeros=false, this is the closest power of two beneath that.
	SkipNormalization bool

	// If the number of input samples is not exactly a power of two, the input batch must either be cut short or filled up with zeros.
	// The default is to cut the input to a power of two. set FillZeros to true, to instead fill the input with zeros to reach the next higher power of two.
	FillZeros bool

	// If FrequencyMetricIndex >= 0, the frequency for every FFT result value will be added as a new metric at the given index.
	// If the index is higher than the total number of input metrics, it will be appended as the last metric.
	// The name of that new metric will be FftFreqMetricName ("freq").
	FrequencyMetricIndex int

	// If SamplingFrequency > 0, it will be used as the total sampling frequency when computing the frequency metric.
	// If this is <= 0, the sampling frequency will be computed automatically from the timestamps of the first and last input sample, and the total number of samples.
	SamplingFrequency float64

	// FatalErrors can be set to true to return errors that occur when processing a batch.
	// Otherwise, the error will be printed as a warning and an empty result batch will be produced.
	FatalErrors bool
}

func (*BatchFft) OutputSampleSize

func (s *BatchFft) OutputSampleSize(sampleSize int) int

func (*BatchFft) ProcessBatch

func (s *BatchFft) ProcessBatch(header *bitflow.Header, samples []*bitflow.Sample) (*bitflow.Header, []*bitflow.Sample, error)

func (*BatchFft) String

func (s *BatchFft) String() string

type BatchRms

type BatchRms struct {
}

func (*BatchRms) ProcessBatch

func (r *BatchRms) ProcessBatch(header *bitflow.Header, samples []*bitflow.Sample) (*bitflow.Header, []*bitflow.Sample, error)

func (*BatchRms) String

func (r *BatchRms) String() string

type ConvexHull

type ConvexHull []Point

func ComputeConvexHull

func ComputeConvexHull(points []Point) ConvexHull

func (ConvexHull) ComputeLowestPoint

func (p ConvexHull) ComputeLowestPoint() (low Point)

type FeatureAggregator

type FeatureAggregator struct {
	bitflow.NoopProcessor
	WindowSize     int           // Applied if >0
	WindowDuration time.Duration // Applied if >0
	UseCurrentTime bool          // If true, use time.Now() as reference for WindowTime. Otherwise, use the timestamp of the latest Sample.
	// contains filtered or unexported fields
}

func (*FeatureAggregator) Add

func (*FeatureAggregator) AddAvg

func (agg *FeatureAggregator) AddAvg(suffix string) *FeatureAggregator

func (*FeatureAggregator) AddSlope

func (agg *FeatureAggregator) AddSlope(suffix string) *FeatureAggregator

func (*FeatureAggregator) MergeProcessor

func (agg *FeatureAggregator) MergeProcessor(other bitflow.SampleProcessor) bool

func (*FeatureAggregator) OutputSampleSize

func (agg *FeatureAggregator) OutputSampleSize(sampleSize int) int

func (*FeatureAggregator) Sample

func (agg *FeatureAggregator) Sample(sample *bitflow.Sample, header *bitflow.Header) error

func (*FeatureAggregator) String

func (agg *FeatureAggregator) String() string

type FeatureAggregatorOperation

type FeatureAggregatorOperation func(stats *FeatureWindowStats) bitflow.Value

type FeatureWindowStats

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

func (*FeatureWindowStats) Flush

func (stats *FeatureWindowStats) Flush(num int)

func (*FeatureWindowStats) Push

func (stats *FeatureWindowStats) Push(val bitflow.Value, timestamp time.Time)

type GetFeatureFunc added in v0.0.56

type GetFeatureFunc func(stats steps.FeatureStats) float64

type MinMaxScaling

type MinMaxScaling struct {
	Min float64
	Max float64
}

func (*MinMaxScaling) ProcessBatch

func (s *MinMaxScaling) ProcessBatch(header *bitflow.Header, samples []*bitflow.Sample) (*bitflow.Header, []*bitflow.Sample, error)

func (*MinMaxScaling) String

func (s *MinMaxScaling) String() string

type PCAModel

type PCAModel struct {
	Vectors            *mat.Dense
	RawVariances       []float64
	ContainedVariances []float64
}

func (*PCAModel) ComponentsContainingVariance

func (model *PCAModel) ComponentsContainingVariance(variance float64) (count int, sum float64)

func (*PCAModel) ComputeAndReport

func (model *PCAModel) ComputeAndReport(samples []*bitflow.Sample) error

func (*PCAModel) ComputeModel

func (model *PCAModel) ComputeModel(samples []*bitflow.Sample) error

func (*PCAModel) Load

func (model *PCAModel) Load(filename string) (err error)

func (*PCAModel) Project

func (model *PCAModel) Project(numComponents int) *PCAProjection

func (*PCAModel) ProjectHeader

func (model *PCAModel) ProjectHeader(variance float64, header *bitflow.Header) (*PCAProjection, *bitflow.Header, error)

func (*PCAModel) Report

func (model *PCAModel) Report(reportVariance float64) string

func (*PCAModel) String

func (model *PCAModel) String() string

func (*PCAModel) WriteModel

func (model *PCAModel) WriteModel(writer io.Writer) error

type PCAProjection

type PCAProjection struct {
	Model      *PCAModel
	Vectors    mat.Matrix
	Components int
}

func (*PCAProjection) Matrix

func (model *PCAProjection) Matrix(matrix mat.Matrix) *mat.Dense

func (*PCAProjection) Sample

func (model *PCAProjection) Sample(sample *bitflow.Sample) (result *bitflow.Sample)

func (*PCAProjection) Vector

func (model *PCAProjection) Vector(vec []float64) []float64

type Point

type Point struct {
	X, Y float64
}

func SortByAngle

func SortByAngle(points []Point) []Point

func (Point) Distance

func (p Point) Distance(other Point) float64

type SpherePoints

type SpherePoints struct {
	bitflow.NoopProcessor
	RandomSeed int64
	NumPoints  int

	RadiusMetric int // If >= 0, use to get radius. Otherwise, use Radius field.
	Radius       float64
	// contains filtered or unexported fields
}

func (*SpherePoints) Sample

func (p *SpherePoints) Sample(sample *bitflow.Sample, header *bitflow.Header) error

func (*SpherePoints) Start

func (p *SpherePoints) Start(wg *sync.WaitGroup) golib.StopChan

type StandardizationScaling

type StandardizationScaling struct {
}

func (*StandardizationScaling) ProcessBatch

func (s *StandardizationScaling) ProcessBatch(header *bitflow.Header, samples []*bitflow.Sample) (*bitflow.Header, []*bitflow.Sample, error)

func (*StandardizationScaling) String

func (s *StandardizationScaling) String() string

Jump to

Keyboard shortcuts

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