median of medians
This commit is contained in:
@@ -80,17 +80,29 @@ func registerWithContributionPredictionForNameForCurrency(reg Register, window t
|
||||
if wouldBe == 0 {
|
||||
wouldBe = 2
|
||||
}
|
||||
return contributions[len(contributions)-wouldBe:]
|
||||
return contributions[len(contributions)-1-wouldBe:]
|
||||
}
|
||||
|
||||
eighth := contributsSlice(7.0 / 8.0)
|
||||
quarter := contributsSlice(3.0 / 4.0)
|
||||
half := contributsSlice(1.0 / 2.0)
|
||||
medianValueDelta := func() float64 {
|
||||
return (4.0*getMedianValueDelta(eighth) + 2.0*getMedianValueDelta(quarter) + 1.0*getMedianValueDelta(half)) / (4.0 + 2.0 + 1.0)
|
||||
medians := []float64{
|
||||
getMedianValueDelta(eighth),
|
||||
getMedianValueDelta(quarter),
|
||||
getMedianValueDelta(half),
|
||||
}
|
||||
slices.Sort(medians)
|
||||
return medians[1]
|
||||
}()
|
||||
medianLapse := func() time.Duration {
|
||||
return (4.0*getMedianLapse(eighth) + 2.0*getMedianLapse(quarter) + 1.0*getMedianLapse(half)) / (4.0 + 2.0 + 1.0)
|
||||
medians := []time.Duration{
|
||||
getMedianLapse(eighth),
|
||||
getMedianLapse(quarter),
|
||||
getMedianLapse(half),
|
||||
}
|
||||
slices.Sort(medians)
|
||||
return medians[1]
|
||||
}()
|
||||
|
||||
latest := func() float64 {
|
||||
|
||||
Reference in New Issue
Block a user