Solved

Anyone know how to modify this function? recip(ms(NOW,mydatefield),3.16e-11,1,1)

Posted on 2013-05-16
9
660 Views
Last Modified: 2013-05-16
I'm using a mathematical function to convert dates in the past into a number that I can use as a multiplier.  Here's is an explanation:

Date Boosting

Boosting more recent content is a common use case. One way is to use a recip function in conjunction with ms.

There are approximately 3.16e10 milliseconds in a year, so one can scale dates to fractions of a year with the inverse, or 3.16e-11. Thus the function recip(ms(NOW,mydatefield),3.16e-11,1,1) will yield values near 1 for very recent documents, 1/2 for documents a year old, 1/3 for documents two years old, etc.  
---------------------

I understand the gist of what it's doing, but I'd like to modify it and don't have the math chops to figure it out.  

I'm basically asking how to soften the curve of this formula, as it seem to 1/2 itself every year away from the current date.  I would like the curve to roughly reduce from 1 to 0 over 10 years - e.g., drop 10% every year a date is away from today.  Anyone have any ideas?  Thanks!
0
Comment
Question by:Xbradders
9 Comments
 
LVL 3

Expert Comment

by:pjevin
ID: 39172657
recip(diff in milliseconds,-3.16e-10,1,1) should do it.
0
 
LVL 27

Expert Comment

by:d-glitch
ID: 39172664
The current function is                        1/(AGE + 1)

One function you might want is         (10 - AGE)/10
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 39172675
Well then why not just use max(10 - ms(NOW,mydatefield)/(1000*60*60*24*365.25), 0)/10?

If you want it to scale to 5 years, then just use 5 in place of both 10s etc.

What it does is calculate the time span in ms and divide it by the approximate number of milliseconds in a year (assuming one leap year every 4 years)
It subtracts the number of years from the target number and then divides. Anything past 10 years will be 0.
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 39172695
Do you want to "soften the curve" or change the curve into a straight line over 10 years?
The reason they use the recip function (1/x) is that even 200 years from now, the document that is 201 years old will have a lower boost.

Instead of 1/AGE, you could use 1/(AGE/5) (which is similar to what pjevin gave you). That will drop to 1/2 after 5 years and down to 1/3 after 10 etc.

My first post uses the (10 - AGE)/10 that d-glitch also mentioned while I was typing up my first answer. The downside to that version is that it flatlines at 0 after 10 years.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:Xbradders
ID: 39172739
Thanks for the input thus far.  Good info.  

I'm using it as a multiplier against a value called Score.  If it reduces to 0, it would 0 out my Score, so I should add 1 to it right?  Doing that would leave me with multipliers from 1 to 2, right?  That would likely have too strong of an affect, so perhaps I'll add 3 to the equation to dilute the multiplier.  Does that sound like the right way to do it?
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 39172756
What's wrong with the score slowly depleting toward 0 but never actually hitting 0?
0
 
LVL 37

Accepted Solution

by:
TommySzalapski earned 350 total points
ID: 39172772
If it is just a multiplier though, 1 seems like a logical baseline so adding 1 to the final result of either approach is fine.

If you want to dilute the equation, I would recommend doing it in the equation. If you want the multiplier to go from 1.5 to 1 in a smooth line over 10 years then use something like

.5*(max(10 - ms(NOW,mydatefield)/(31557600000), 0)/10) + 1
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 39172780
So the idea is
MAX_DIFF*(max(YEARS - AGE_IN_YEARS, 0)/YEARS) + MIN_SCORE

Fill those in with whatever you want. I used the following in my last post.
MAX_DIFF = .5
YEARS = 10
MIN_SCORE = 1
0
 

Author Comment

by:Xbradders
ID: 39173062
That's excellent Tommy!  Just what I needed.  

The reason going from 1 to .001 (or whatever the MIN would be), is that this date relevancy is only part of my overall scoring of relevance.  The main Score portion is still more important.  So if I had:
Score .85 and Date relevancy of .001  
  It would fall way below a record with a much lower score:
Score .25 and Date relevancy of 1.

I'll be working out this balance for a while, as I don't know the exact impact I want the date relevancy to have.  I'm thinking it should only sway the score by 20-30%, so I think the equation you've detailed should be a good starting point, that I can tweak after testing.  Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Octane 98 vs 95 petrol / gasoline : mileage,  pros & cons 10 106
Graph 2 74
STDEVP in SQL 2 53
Normalised finishing position 2 41
The greatest common divisor (gcd) of two positive integers is their largest common divisor. Let's consider two numbers 12 and 20. The divisors of 12 are 1, 2, 3, 4, 6, 12 The divisors of 20 are 1, 2, 4, 5, 10 20 The highest number among the c…
This article provides a brief introduction to tissue engineering, the process by which organs can be grown artificially. It covers the problems with organ transplants, the tissue engineering process, and the current successes and problems of the tec…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now