Thursday 5 April 2018

algorithms - Base of logarithm decrease when variable count increase




I run a large online platform where users submit articles and earn points. I am working on an algorithm where the more comments they submit, the higher score they will receive.



In its simplest stripped down form, this is how the algorithm looks like (the variables are the user's count for each contribution):



( $total_articles * log($total_articles_featured , 1.$total_comments) ) = Score


My aim with the algorithm is to make it valuable to have a high $total_comments count. And I need the $total_comments count be added to the base of the logarithm.



So, with the above calculation, if the user has 350 comments, then the log base will be 1.350.




The obvious problem is that with this calculation, the more comments the user has, the lower score they will receive. I need this to be the opposite. So that the log base decimals decreases whenever the user's $total_comments count increases. And the value should never be 0 (because that will set the logarithm into infinity).



How would I solve this?



When answering, if you are using calculations beyond basic maths, kindly make a note of what each function is called.


Answer



In your formula you wrote $a\cdot\log_{1.c}b$. In the plots, I'm plotting the function which would go in the base of the logarithm. So the function we want is a function which is always above 1 and is decreasing towards 1



$$a\log_{1.c}b=\frac{a\log b}{\log 1.c}$$




This was what you suggested in your question, and I don't think this is what you wanted



saw tooth like function



Now if we replace the base with



$$1+\exp (-c/55)$$



We get this




decreasing function



By increasing $55$ you can make this curve flatten even slower. Here the function is with $550$ instead of $55$ (notice the numbers at the bottom)



slower decreasing plot



I think the function you would want is this:



$total_articles * log($total_articles_featured , 1 + exp(-$total_comments/550.))



However you could change the constant 550. to change the rate of flattening.






Edit: Alternative solution



In the comments you expressed interest in a solution with a straight line which then flattens, I will explain how it works here.
The difference between the solutions is that with this solution, comments loser their value slower at the start, but later they lose their value faster then the previous solution.




Actually what I suggested is very simple, the function has two different formulas in the area 1 to say 1000 comments and a different formula above 1000 comments.



Here's finding a simple function like this:
The first task is finding a linear equation which goes from 2 to $1+\exp(-1000/550)=1.162320611...$



The equation for a linear function is



$$ax+b$$



And $b$ is the value of the function at $0$, and since we want it to start at $2$, $b$ will be $2$.
The next we need to find is $a$ and we can do this because we want the value of the function at $1000$ to be $1+\exp(-1000/550)=1.162320611...$




$$1000a+2=1.162320611...$$
Which when solved is
$$a = -0.000837679$$



This linear equation looks like this:



linear function



The line looks great in the start but we reach problems somewhere since the function goes below $1$ and we don't want that.
There is a solution, we make a piecewise function.




$$
f(x)=\left\{
\begin{array}{lr}
-0.000837679x+2&\quad \text{if }x<1000\\
1+\exp (-c/550) &\text{if }x\ge 1000
\end{array}
\right.
$$



Which gives us:




piecewise function



And that function will never reach $1$.



If you want to use the function above this would be the code



$total_articles * log($total_articles_featured, $total_comments < 1000 ? 2-$total_comments/1193.7747 : 1 + exp(-$total_comments/550.))



We might want this function to have a less abrupt cut in it, and we can decrease the cut by increasing the point where we switch from line to flattening formula. However we will never remove the cut completely.
I think the other solution is better because when we get to a point where we almost cant see the cut anymore, the linear function decreases so slowly that the amount of points each comment gives is almost the same unless you post a truly great amount of comments.


No comments:

Post a Comment

real analysis - How to find $lim_{hrightarrow 0}frac{sin(ha)}{h}$

How to find $\lim_{h\rightarrow 0}\frac{\sin(ha)}{h}$ without lhopital rule? I know when I use lhopital I easy get $$ \lim_{h\rightarrow 0}...