4
$\begingroup$

I am trying to find a mathematical function that would provide certain weighting to the values of my algorithm. Namely, having two values, x,y, I would like to provide a function that would favour big differences between x and y. Ideally, it would return 1, if x = -inf and y = +inf (or vice versa) and 0, if they are equal. On top of that, I would like it to be non-linear in growth.

I hope the above makes sense. Thank you very much in advance for your comments and answers.

2 Answers 2

3

You can define a lot of such functions, the most simple choice being $1-\mathrm e^{-|x-y|}$ which admits all the requirements you've requested. We can also make it even more nonlinear: $$ 1 - \mathrm e^{-|x^3-y^5|} $$ not to depend explicitly on $|x-y|$ if you would like to avoid that.

You can also consider $1-\mathrm e^{-|x-y|^p}$ for $p>0$. If you would like to weight more huge differences in $x,y$ then choose $p>1$, otherwise choose $p<1$. If you know that the maximum difference is $D$ then you can simply use $$ \left(\frac{|x-y|}{D}\right)^p $$ where the choice of $p$ follows the same reasons.

  • 0
    Thank you very much Ilya. I further noticied that the basic function quite quickly reaches "high" weight values. if x and y differ by only 1, the value would still be at around 0.6. My values would most likely differ by 10-20, or even more, so I would like to be able to see big difference between 20 and 200, if that is the case. Should I simply divide the difference by 100 or other constant of mine or is there a better way to achieve what I described? thanks2012-05-30
  • 0
    Another update: if I know, taht maximum difference is D, how can I make this equal to 1, using the above function, and rescale all the other, smaller values respectively?2012-05-30
  • 0
    @Bober02: updated2012-05-30
1

Any strictly monotonic function $f$, such that $\lim \limits_{x \rightarrow +\infty} f(x) \neq \infty$ could be used after a bit of linear transformations. Aside from what Ilya suggests, other natural choices could be $$1 - \frac{1}{1+|x-y|}$$ or $$\frac{2\arctan |x-y|}{\pi}$$ There is a lot of freedom here, if you know exactly what you want.