\documentclass{article} % Uses 10pt
\usepackage[utf8]{inputenc}
\topmargin=-1in    % Make letterhead start about 1 inch from top of page
\textheight=8in  % text height can be bigger for a longer letter
\oddsidemargin=0pt % leftmargin is 1 inch
\textwidth=6.5in   % textwidth of 6.5in leaves 1 inch for right margin

\begin{document}
%\begin{letter}{Resource scoring}

\section{Resource scoring}

Proposal for the new scoring formula:

$$ S = \sum _{i = 1} ^ n e^{-d_i} e^{k_i} $$

\noindent Where:

\begin{itemize}
    \item $S$ - total score
    \item $i$ - index of the DeskopEvent associated with the specific resource (from 1 to n)
    \item $d_i$ - time passed since the $i^{th}$ DeskopEvent happened
    \item $k_i$ - coefficient depending whether the DeskopEvent is read event or modify event
\end{itemize}

\subsection{Explanation and reasoning}

\begin{itemize}
    \item The more time passes, the event becomes less relevant, thus $e^{-d}$
    \item Viewing and saving files have different importance, thus different coefs.
    \item $e^k$ is being used instead of just $k$ because it produces prettier math (read on)
\end{itemize}

\subsection{Improvements over the current implementation}

\subsubsection{Updateable score}

Currently, the score is calculated each time from scratch - analyze all
DeskopEvents, and process them. With the new formula, this is no longer the case.

\vspace{0.5cm}
\noindent Let $S_1$ be the score at some point in time.

$$ S_1 = \sum _{i = 1} ^ {n_1} e^{-d_i} e^{k_i} $$

\noindent And $S_2$ score at some point in time after $S_1$ was calculated

$$ S_2 = \sum _{i = 1} ^ {n_2} e^{-d'_i} e^{k_i} $$

\noindent $n_2 \geq n_1$ and $d'_i = d_i$ for $i = 1 .. n_1$ - the first $n_1$ events are the same
ones we had in $S_1$ and we have some new ones. We can write the above formula as

 $ S_2 = \sum _{i = 1} ^ {n_1} e^{- d_i - d} e^{k_i}
       + \sum _{i = n_1 + 1} ^ {n_2} e^{- d_i} e^{k_i} $

 $\Leftrightarrow S_2 = e^{-d} \sum _{i = 1} ^ {n_1} e^{- d_i} e^{k_i}
       + \sum _{i = n_1 + 1} ^ {n_2} e^{- d_i} e^{k_i} $\\

\noindent Which, with the knowledge of $S_1$ becomes:

 $$S_2 = S_1 \cdot e^{-d} + \sum _{i = n_1 + 1} ^ {n_2} e^{- d_i} e^{k_i} $$

\subsubsection{No special cases}

Implicit events like the last modified date when no DeskopEvent exist are not
a special case anymore - it can be covered in the formula with a simple change
of the weight coeficient $k_i$.

\subsection{Regressions from the current implementation}

\subsubsection{Not including the rating}

From my point of view, this is not an important regression - both
score and rating are in the database and if we want to use them both
when sorting the results, we can.

On the other hand, I have aversion from having directly dependant data
in the database.

\subsubsection{No handling of types and file patterns}

This is (for me) the only real drawback compared to the current code.

\subsection{Appendix: Current score}

The database (Nepomuk) holds the value of the score the last time
it got updated. If it hasn't been updated for a while, the real score
will be:

$$ S_{real} = e^{-d} \cdot S_{saved} $$

\noindent where $d$ is the time since the update.

\end{document}






