Function to express a time interval with results between 0 and 1 Its my first time on here and my maths is poor so please be kind. I am working on a Masters dissertation focused on document clustering methods in which I would like to apply a weight based on the time interval between two documents. 
I am looking for some help coming up with a function to express a time interval with results between 0 and 1. The reason I want to map the results to a maximum value of zero is that this is being applied as a weight to a cosine similarity metric where identical articles would receive a cosine measurement of 1 etc.
Example 1, the date difference between 31/05/2015 and 20/06/2015 is 9 days.
Example 2, the date difference between 31/05/2015 and 20/01/2015 is 129 days.
I would like to apply a function whereby example 1 has a higher value (towards the 1 end of the scale) and example 2 has a lower value (towards the 0 end of the scale). If the date difference was only 1, the value of 1 should apply.
I hope this makes sense. Any help anyone can offer me would be greatly appreciated. 
Thank You
Claire
 A: Do you have a maximum and minimum date? If so, I suggest you simply divide the number by the number of days between the maximum and the minimum.
A: The simplest approach in my opinion is to consider the function
$$
w(d) =\frac{1}{d},
$$
where $d$ is the number of days difference. It is obvious that $w(1) = 1$ and that $0<w(d)<1$ for all $d\geq1$, as you wanted, and by coincidence, this function also has the property that $w(9)=\frac{129}{9}w(129)$, or more generally 
$$
w(d_1) = \frac{d_2}{d_1} w(d_2). 
$$
You can generalize this function if you want: 
$$
w_A(d) = \frac{A+1}{d+A}
$$
also obeys all your properties for a positive constant $A$. Note that this is not the most general function satisfying your constraints. Even after replacing $d$ with some monotonically ascending function of $d$, $w$ will still not be the most general function.  
A: One standard approach in this kind of situation is to consider some discount factor $d<1$ such that the value of an example decreases by this factor for each time unit which has passed, i.e. for an example with initial value $v_0$ and age $t$, you would use the value $v = v_0 \cdot d^t$.
