Skew a value in the range [0.0, 1.0].

139 Views Asked by At

I have a variable v that can take a value from 0.0 to 1.0. I want a function to left-skew the value, producing w. By "left skew" I mean that any value of v will be increased, but more so for lower values and less so for higher values, so that there will be more values in w "bunched together" the nearer you get to 1.0. (My math is a but rusty so I apologize if I'm not asking this using the correct terminology.)

For an intuitive example (not to scale; these are arbitrary values to explain the idea), a value v of 0.4 might yield a value w of 0.5, while a value v of 0.91 might only yield a value w of 0.92. (Ideally there would be some other variable that controlled the amount of skew, and perhaps another variable that controlled the weight or slope of the skew. But I want to start simple!) However an input v of 0 or 1 would still yield an output w of 0, and 1, respectively (i.e. the bounds of the range are fixed).

Another way to look at this is to assume that the values in v are right-skewed, and we want to "unskew" them to make a uniform distribution.

This is probably Math 101 or Trigonometry 101, and there's probably some simple sin/cos function or something like that. Thank you in advance for helping my brain get oriented to review these elementary concepts.

2

There are 2 best solutions below

7
On

Consider $w = v + g(v)$, where $g(v)$ is the addition to $v$ that gives $w$. Presumably, you want the following to hold for $g(v)$:

  1. $g$ is defined in $[0,1]$.
  2. $g(1)=0$ . This ensures that when $v$ is 1, so is $w$.
  3. $g(v) \geq 0$. This ensures that $w \geq v$.
  4. $-1 \leq g'(v) \leq 0$. This ensures that $v$ will be increased more for smaller $v$, and that $w$ is monotonic in $v$.

An example function that accomplishes this is $$ g(v;r) = \frac{1}{r}\left(1-v^r \right), $$ where $r\geq 1$ is your parameter to be fixed. I have included some examples in the image below. Smaller $r$ increases the skew.

enter image description here

4
On

Is this question really this difficult? Apparently the most difficult part is visualizing graphically what I intuitively want and then explaining it.

The description below does not match exactly what I described above; in particular, as Philip Winchester pointed out, initially values increase more rapidly (i.e. a larger number will increase by more than a smaller number), until tapering off later (so that the opposite happens). I am contemplating this and determining what I actually want, and getting a better grip on graph intuition. For the meantime, here is my original (perhaps incorrect or incomplete) answer.

The responses made be realize I need to be thinking about what sort of graph I would want. And Brian Tung's comment about a power function put me on the right track—the graph of a power function was just curved the wrong way. Thinking a bit, I realized that "flipping" the graph was just a matter of subtracting from 1.0 in the appropriate places, based upon whether I wanted to flip the x or y axis. (I wanted to flip both.) Pulling out the Windows 10 graphing calculator and figuring out how to use it quickly yielded this:

$$y = 1 - (1 - x)^3$$

enter image description here

And I can increase the steepness of the slope just by increasing the power.

I am still contemplating exactly what I want; I'll update all of this as I come up with more understanding.