Add forecast daypart derivation
This commit is contained in:
20
internal/forecast/thresholds.go
Normal file
20
internal/forecast/thresholds.go
Normal file
@@ -0,0 +1,20 @@
|
||||
package forecast
|
||||
|
||||
func DifferenceAtLeast(previous float64, current float64, threshold float64) bool {
|
||||
return abs(current-previous) >= threshold
|
||||
}
|
||||
|
||||
func CrossesAtOrAbove(previous float64, current float64, threshold float64) bool {
|
||||
return previous < threshold && current >= threshold
|
||||
}
|
||||
|
||||
func CrossesBelow(previous float64, current float64, threshold float64) bool {
|
||||
return previous >= threshold && current < threshold
|
||||
}
|
||||
|
||||
func abs(value float64) float64 {
|
||||
if value < 0 {
|
||||
return -value
|
||||
}
|
||||
return value
|
||||
}
|
||||
Reference in New Issue
Block a user