Looking for a Formula to apply to a set of numbers (input) that will output a certain result.

59 Views Asked by At

Sorry for the crude title: I'm looking for a formula to apply to each element of an "input set" of numbers that will output elements in another "output set" with the following characteristics:

  • The low numbers and high numbers in the output set should stay relatively tight and close together to the low and high of the input set.
  • The middle numbers in the output set should increase expoentially but level off.
  • Doesn't have to be stochastic

For example, if we use the input set {1,2,...,10} we will get an output set of {1, 1.3, 1.8, 3, 6, 8, 8.6, 8.9, 9.1, 9.2}.

I was thinking of using a transformed cotangent formula, but am unsure of how to transform it in such a way that would apply to this scenario.

2

There are 2 best solutions below

2
On

What about something like:$$f(x)=x_0+\left(\frac{x_n-x_0}{\ln{\frac{x_n}{x_0}}}\right)\ln\left(\frac{x}{x_0}\right)$$for$$x=x_0,x_1,...,x_n$$

For the end points this gives:$$f(x_0)=x_0$$$$f(x_n)=x_n$$ For the example you gave of {1, 2, ..., 10}

this will generate {1, 3.71, 5.29, 6.42, 7.29, 8.00, 8.61, 9.13, 9.59, 10}

The function grows logarithmicly from 1 to 10.

0
On

Here are two different options, if I am understanding what you want correctly. Say your smallest integer is $a$ and your largest $b$,

\begin{equation} f(x) = b - \frac{b-a}{1 + e^{(x-(b+a)/2)}} \end{equation}

which will give $\{1.099, 1.264 1.683, 2.642, 4.398, 6.602, 8.358, 9.317, 9.736, 9.901\}$ for the inputs 1 through 10. Here is a graph

enter image description here

This actually does give "exponential" behavior in the middle, and you can control the steepness in the middle of the range by multiplying the $(x-5.5)$ in the exponent by a factor greater than one to make it "steeper" and less than one to make it less "steep".

Another option is to use something like a quintic polynomial, which isn't exponential but would seem to give the behavior you are looking for. For instance,

\begin{equation} p(y) = 54y^5 - 135y^4 + 90y^3 + 1 \end{equation} with $y = (x-1)/9$ and $x$ your input integers 1 through 10, yields the outputs $\{1,1.1038,1.6877,2.889,4.570,6.430,8.111,9.312,9.896,10\}$. Here is a graph of the polynomial:

enter image description here To solve for the polynomial coefficients, just set up the matrix system \begin{equation} \begin{bmatrix} 1 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 2 & 0 & 0 & 0 \\ 1 & 1 & 1 & 1 & 1 & 1 \\ 0 & 1 & 2 & 3 & 4 & 5 \\ 0 & 0 & 2 & 6 & 12 & 20 \end{bmatrix} c = \begin{bmatrix} \text{min output} \\ 0 \\ 0 \\ \text{max output} \\ 0 \\ 0 \end{bmatrix} \end{equation} The coefficients $c_i$ form the polynomial $p(y) = c_0 + c_1 y + ... + c_5 y^5$. Then use the transformation $y = (x - 1)/(b - a)$, and your input integers are $x$ and your output values are $p(y(x))$.