Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
DunZane opened this issue Sep 10, 2024 · 1 comment
Closed

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

DunZane opened this issue Sep 10, 2024 · 1 comment
Labels
kind/bug Something isn't working

Comments

@DunZane
Copy link

DunZane commented Sep 10, 2024

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++ {.

@DunZane DunZane added the kind/bug Something isn't working label Sep 10, 2024
@DunZane DunZane closed this as completed Sep 10, 2024
@DunZane DunZane reopened this Sep 10, 2024
@DunZane DunZane closed this as completed Sep 10, 2024
@DunZane
Copy link
Author

DunZane commented Sep 10, 2024

i think i got some wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant