Logarithmic pattern from 0 to 1 to calculate probability.

38 Views Asked by At

I'm sorry if this is badly explained, I'm really a computer programmer. I have 13 different variables all initially assigned to a integer of 0.5.

thr = 0.5 act = 0.5 com = 0.5

I want to generate a function in which a user can input a number from 1-10 and it'll increase the variable.

E.g. ThrInput = 4 Thr is now reduced by a small amount.

ActInput = 9 Act is now increase by a large amount.

The must never exceed 1 due to this number being used as a probability elsewhere. I also need the function to be able to increase by less the closer it gets to 1 or 0 (Logarithmic pattern).

Any help would be much appreciated,

Regards,

Matt.


Reasoning behind it is, a user can rate a movie with a genre (increasing or decreasing the chance of getting that genre movie show again) but never want the probability to hit 1 or 0 because that means that means that genre will either be 100% of all movies or 0%.

1

There are 1 best solutions below

1
On BEST ANSWER

Try the following function: $$ f(x)=\frac1{1+e^{a(x-\bar x)}}, $$ where $\bar x$ is the mean input value (in your case $5.5$) and $a>0$ is an adjustable parameter. The larger is the parameter the closer will be the result to $0$ (for $x_\text{min}\le x< \bar x$) or to $1$ (for $\bar x< x\le x_\text{max}$). Observe the symmetry wrt. the value $x=\bar x$. If you would like to use even number of equally spaced possible inputs (as in the case $x=1\dots10$) there is no symmetric choice of input for the mean value $f(x)=0.5$. For odd number of inputs (for example $x=0\dots10$) it is easily possible.