I implemented a linear function for a search algorithm, that boosts a document according to its time since upload. So the newer a document the more likely it will be presented for a given search term. Maximum age that will be boosted is 365 days (MaxDays
) to a maximum of 10 points (MaxBoost
).
float MaxDays = 365
float MaxBoost = 10
float calculatedBoost = MaxBoost - (daysPassedSinceUpload * (MaxBoost / MaxDays))
But I am not yet satisfied with the results. So I wonder if an exponential function would work better, where the y-axis will be hit at 10 and the x-axis at 365 (see image). Unfortunately it's been a few years since I last did any exponential function in school. Can you please help me to figure out a working function? All I know for now is that is has to be somthing like y=0.5x. Obviously different to cross the axis at right spots. Thanks
The issue with exponential functions is they don't have a root (e^-x
never reaches 0, 0 is an asymptote) It is still possible though to use an exponential function but that's gonna require a bit of math.
asymptote = -1
t = ln(asymptote/(asymptote-maxAge)) / maxAge
calculatedBoost = (maxBoost - asymptote) * exp(daysPassedSinceUpload*t) + asymptote
https://www.desmos.com/calculator/vedi0blktp
A better solution might be to use a polynomial! This is also WAYYYY easier n is the degree (strength) of the polynomial
n = 3
calculatedBoost = pow(1-daysPassedSinceUpload/maxAge, n) * maxBoost