1

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). enter image description here 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

1
  • 1
    0.5^(dayspassed/halflife) ought to do what you want with halflife ~100 days. But if you do want it to go negative after MaxDays then subtract off 0.5^(MaxDays/halflife). and rescale. Spreadsheets are good for picking and exploring ad hoc functions. Commented Jul 25, 2024 at 10:24

1 Answer 1

1

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

https://www.desmos.com/calculator/jbnza17ma0

Sign up to request clarification or add additional context in comments.

2 Comments

Thx. You're right, the polynomial is way easier indeed. But now x is not timePassedSinceUpload anymore. It is (365 - timePassedSinceUpload), which I can work with.
that for pointing that out, I'll edit the answer to fix that error. Also x is not (365 - daysPassedSinceUpload) please check the answer for the correct version, I accidentally swapped the signs...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.