Best way to skew a mpping function

Discussion in 'Physics & Math' started by Jennifer Murphy, Nov 23, 2018.

  1. Jennifer Murphy Registered Senior Member

    Messages:
    239
    I would like to map the numbers on the domain (0,10) onto the same range, but skewed so that the midpoint (5,y) can be anything from (5,.001) to 5,9.999) and the other values will be skewed proportionally and so that y is monotonically increasing. I also need f(0)=0 and f(10)=10.

    I tried fitting a parabola to the three points ((0,0), (5,y), (10,10)), but y goes above 10 or below 0.

    Please Register or Log in to view the hidden image!


    Is there a better function than a parabola or am I doing it wrong?
     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. Neddy Bate Valued Senior Member

    Messages:
    2,548
    I'm thinking maybe a hyperbola, but I'm not really sure.

    Please Register or Log in to view the hidden image!



    I drew the above curves over your graph using a curved line tool in a paint program. Whatever they are, their axis of symmetry seems to be a line running from (0, 10) to (10, 0).
     
    Last edited: Nov 23, 2018
    Jennifer Murphy likes this.
  4. Google AdSense Guest Advertisement



    to hide all adverts.
  5. Jennifer Murphy Registered Senior Member

    Messages:
    239
    How did you determine the coefficients for those graphs?

    I'm looking for a function that will pass through (0,0), (5,m), and (10,10), where 0<m<10 & y is monotonically increasing.

    Those curves do appear to meet those requirements. Can you show me how to calculate the coefficients for a function that will pass through these points:
    • (0,0) (5,6) (10,10)
    • (0,0) (5,7) (10,10)
    • (0,0) (5,8) (10,10)
    • (0,0) (5,4) (10,10)
    • (0,0) (5,3) (10,10)
    Thanks
     
  6. Google AdSense Guest Advertisement



    to hide all adverts.
  7. Neddy Bate Valued Senior Member

    Messages:
    2,548
    I didn't, I just drew them in a paint program.

    I don't think a hyperbola is required after all. The parabola should be fine.

    I haven't tried it yet, but I think this method should work for all your 3-point scenarios:



    But we also have to figure out how to rotate the parabola 45 degrees, so the axis of symmetry is as shown in my paint drawing.
     
    Last edited: Nov 24, 2018
  8. Jennifer Murphy Registered Senior Member

    Messages:
    239
    I don't think a parabola will work. If we rotate it, then it won't go through (0,0). I tried several curve fitting websites. None of them came up with a parabola that works.

    I thought I had it using a combination of several functions. In this diagram, the dotted black line represents the skewing space that is available between the linear function and the max of 10. The red function goes from 0 to 1 to 0 and in intended to apply a corresponding fraction of the available space to be added. The remaining curves are the result of multiplying the first two functions and the ratio of the target value for f(5). It fails the monotonically increasing requirement when m gets close to 5.

    Please Register or Log in to view the hidden image!

     
  9. przyk squishy Valued Senior Member

    Messages:
    3,203
    How about \(\displaystyle f(x) = 10 \biggl( \frac{x}{10} \biggr)^{p}\)? Choose \(\displaystyle p = \log_{2}(10/y) = \frac{\log(10/y)}{\log(2)}\) to get \(f(5) = y\).
     
    Jennifer Murphy likes this.
  10. Jennifer Murphy Registered Senior Member

    Messages:
    239
    Wow!!! That works. Thanks.

    Do you have the time to go through the derivation?
     
  11. przyk squishy Valued Senior Member

    Messages:
    3,203
    Depends which part you're asking about. For the function there isn't really a derivation since the properties you describe in your opening post aren't enough to uniquely identify any one function. I just happened to know that for a power \(p > 0\), \(x^{p}\) behaves roughly like what you asked for except in the range 0 to 1. That is, \(0^{p} = 0\), \(1^{p} = 1\), it increases monotonically, and it increases more quickly at the beginning for \(p < 1\) and more quickly towards the end for \(p > 1\). The function I posted is just this but adjusted to work in the range 0 to 10 instead of 0 to 1. It's not the only thing you could do but it's something simple that seems to fit what you asked for.

    For the specific value of \(p\), you want \(f(5) = 10 \cdot (5 / 10)^p = y\). You can rearrange that to \(2^p = 10 / y\). Then taking the base-2 logarithm \(\log_{2}(\;\cdot\;)\) of both sides gives \(p = \log_{2} (10/y)\).

    Depending on what kind of calculator or software you're using, you may already have a function that calculates the base-2 logarithm for you (e.g., there's one called log2 in Matlab/Octave) or you can use either the natural or base-10 log to compute it via \(\displaystyle \log_{2}(x) = \frac{\log(x)}{\log(2)}\).
     
    Last edited: Nov 26, 2018
    Jennifer Murphy likes this.
  12. Neddy Bate Valued Senior Member

    Messages:
    2,548
    Here is another way you could do it, unless you prefer not to have linear functions or non-differentiable points:
    I am calling your middle point (x,y)=(p,q):

    For the range from x=0 to x=p you could use this function:
    y = (((q-0)/(p-0))*x) + 0

    And for the range from x=p to x=10 you could use this function:
    y = (((10-q)/(10-p))*x) + (10 - ((10-q)/(10-p))*10)

    That approach seems to meet all of the criteria given in the OP:

    Please Register or Log in to view the hidden image!



    ...

    Derivation of the second equation, for reference:
    Equation of a line:
    y = mx + b ................................................. 1
    Where m is the slope:
    m = (10-q)/(10-p) .....................................2
    Substituting eq.1 into eq.2:
    y = (((10-q)/(10-p))*x) + b ...................... 3
    Substituting x and y of a known point (x,y)=(10,10):
    10 = ((10-q)/(10-p))*10 + b .................... 4
    Solve for b which is the y-intercept:
    b = 10 - ((10-q)/(10-p))*10 ..................... 5
     
    Last edited: Nov 26, 2018
  13. Neddy Bate Valued Senior Member

    Messages:
    2,548
    Here's another linear approach which is more symmetrical than my previous one. The maths are not as straightforward, though:

    Please Register or Log in to view the hidden image!

     
    Jennifer Murphy likes this.
  14. Jennifer Murphy Registered Senior Member

    Messages:
    239
    Thanks
     
  15. Jennifer Murphy Registered Senior Member

    Messages:
    239
    I considered using separate functions, but I really need one continuous function. Thanks.
     

Share This Page