Skip to content

Is this an oversight in MaxValue's estimators? #912

@dunzane

Description

@dunzane

Describe the bug
the code under pkg/prediction/dsp/estimators.go

func (m *maxValueEstimator) GetEstimation(signal *Signal, periodLength time.Duration) *Signal {
	nSamplesPerPeriod := int(periodLength.Seconds() * signal.SampleRate)
	estimation := make([]float64, 0, nSamplesPerPeriod)

	nSamples := len(signal.Samples)
	nPeriods := nSamples / nSamplesPerPeriod

	for i := nSamples - nSamplesPerPeriod; i < nSamples; i++ {
		maxValue := signal.Samples[i]
		for j := 1; j < nPeriods; j++ {
			if maxValue < signal.Samples[i-nSamplesPerPeriod*j] {
				maxValue = signal.Samples[i-nSamplesPerPeriod*j]
			}
		}
		estimation = append(estimation, maxValue*(1.0+m.marginFraction))
	}

	return &Signal{
		SampleRate: signal.SampleRate,
		Samples:    estimation,
	}
}

Is that right use for j := 1; j < nPeriods; j++ {.From the introduce in https://gocrane.io/zh-cn/docs/core-concept/timeseries-forecasting-by-dsp/ seems that why should use for j := 1; j <= nPeriods; j++ {.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions