Sigmoid functions for a biased random number generator

295 Views Asked by At

I'm trying to create a random number generator biased toward certain values. To do this I'm using a random number [0,1] as the parameter for a sigmoid curve. I've found the perfect curve to get the results I want,

$c\left( \frac{1}{1+exp(-ax + b(a-16) + 8))}\right) + (1-c)x$,

where $a = [16,\infty)$ is the tightness of the bias, $b = [0,1]$ is the position of the bias and $c = [0,1]$ is the strength of the bias.

However, I need this as a function of y, as it biases away from the number if I plug in an x value at the moment. Here's an example of how I want to find a random number.

I've tried to inverse this function and have got stuck. When $c=1$, it's a lot simpler and I've got the function,

$-c\frac{ln|x^{-1} - 1|+b(16-a)-8}{a}$.

However, when $c\neq1$, I cannot find the inverse, and simply adding $(1-c)x$ as before doesn't work due to the asymptotes at $x=0$ and $x=1$.

Am I missing something obvious or is there a better way to do what I want? I wan't this to be as computationally simple as possible! You can play around with the curves in desmos here.

1

There are 1 best solutions below

1
On BEST ANSWER

I ended up using the function $\frac{1}{a^{|x-m|}}$ where $m$ is the value I'm biased toward and $a = 1 + \frac{b^2}{n}$ where n is the interval of x, and b is the strength of the bias. Using integration, I picked a random area between the min and max $x$ values and solved for $x$.