Scaling A Pair Of Numbers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Maverick22
    SBR Wise Guy
    • 04-10-10
    • 807

    #1
    Scaling A Pair Of Numbers
    Situation:

    I have a pair real floating point numbers from (-∞, +∞) which I compare using relational operators ( <, >, <=,>=,==)

    For the sake of being visually pleasing, I need to find a way to represent these number scaled down to [-100,+100]

    I cant do modulus division because if the numbers are say (1001, 1) the (mod 100) of each number would be 1. Which does me no good relationally

    Regular Division doesn't work either...

    Can someone help me figure this out? Thanks!
    Last edited by Maverick22; 06-29-10, 12:27 PM. Reason: Fixed Infinity Symbol
  • Ganchrow
    SBR Hall of Famer
    • 08-28-05
    • 5011

    #2
    Originally posted by Maverick22
    Situation:

    I have a pair real floating point numbers from (-ꝏ,ꝏ) which I compare using relational operators ( <, >, <=,>=,==)

    For the sake of being visually pleasing, I need to find a way to represent these number scaled down to [-100,100]

    I cant do modulus division because if the numbers are say (1001,1) the (mod 100) of each number would be 1. Which doest me no good.

    Regular Division doesn't work either...

    Can someone help me figure this out? Thanks!
    I can't read the characters in your specified domain but I'll just assume they're meant to be (-∞ , +∞).

    That said, there's no linear bijective mapping (i.e., both 1-1 and onto) between the set of reals and any a given subset with finite endpoints.

    But if you really needed the bijectivity and you were OK with a non-linear mapping you could try the inverse of the logit() function translated about the origin and scalar multiplied to yield the desired range of (-100, +100). Specifically:
    F(x) = 200 * invlg(x) - 100
    F(x) = 200 1 + e-x - 100
    Where eX is the base of the natural logarithm raised to the X power (=exp() in Excel.)

    This would map:
    ±∞ → ±100
    ±35 → ~±99.999999999985789145284798
    ±2.944438979 → ~±90
    ±1.945910149 → ~±75
    ±1.098612289 → ~±50
    ±0.510825624 → ~±25
    0 → 0
    Which could clearly wreck havoc on widely ranging floating points values.

    If you wanted to scale it a bit differently so that, say, ±x0 mapped to ±y0 you'd need to include a scale factor (call it σ) such that:

    σ = -x0 / ln( 200 y0+100 - 1)
    F(x;σ) = 200 1 + e-x/σ - 100

    So if you wanted to guarantee a mapping of 100,000 to ~90 (say), you would use:
    σ ≈ 33,962.3272
    Yielding:
    ±∞ → ±100
    ±100,000 → ~±90
    ±66,088 → ~±75
    ±37,311 → ~±50
    ±17,349 → ~±25
    0 → 0

    If you needed a linear transformation and you could specify limits on your domain endpoints (call them a & b) then the mapping of ±x0 ∈ [a, b] → ±y0 ∈ [-100, 100] is just be the line segment with endpoints (-100, a) and (+100, b), which is:
    F(x) = 100*(a + b - 2x) a - b
    Comment
    • unusialsusp5
      SBR MVP
      • 04-18-10
      • 4198

      #3
      what an idiotic question about nothing
      Comment
      • Maverick22
        SBR Wise Guy
        • 04-10-10
        • 807

        #4
        Originally posted by Ganchrow
        I can't read the characters in your specified domain but I'll just assume they're meant to be (-∞ , +∞).

        That said, there's no linear bijective mapping (ie., 1-1 and onto) between the set of reals and any a given finite subset.

        But if you really needed the bijectivity and you were OK with a non-linear mapping you could try the inverse of the logit() function translated about the origin and scalar multiplied to yield the desired range of (-100, +100). Specifically:
        F(x) = 200 * invlg(x) - 100
        F(x) = 200 1 + e-x - 100
        Where eX is the base of the natural logarithm raised to the X power (=exp() in Excel.)

        This would map:
        ±∞ → ±100
        ±35 → ~±99.999999999985789145284798
        ±2.944438979 → ~±90
        ±1.945910149 → ~±75
        ±1.098612289 → ~±50
        ±0.510825624 → ~±25
        0 → 0
        Which could clearly wreck havoc on widely ranging floating points values.

        If you wanted to scale it a bit differently so that, say, ±x0 mapped to ±y0 you'd need to include a scale factor (call it σ) such that:

        σ = -x0 / ln( 200 y0+100 - 1)
        F(x;σ) = 200 1 + e-x/σ - 100

        So if you wanted to guarantee a mapping of 100,000 to ~90 (say), you would use:
        σ ≈ 33,962.3272
        Yielding:
        ±∞ → ±100
        ±100,000 → ~±90
        ±66,088 → ~±75
        ±37,311 → ~±50
        ±17,349 → ~±25
        0 → 0

        If you needed a linear transformation and you could specify limits on your domain endpoints (call them a & b) then the mapping of ±x0 ∈ [a, b] → ±y0 ∈ [-100, 100] is just be the line segment with endpoints (-100, a) and (+100, b), which is:
        F(x) = 100*(a + b - 2x) a - b
        Phew... what a read. I will try to code this up today, and let you know how it goes. I had passing thoughts yesterday of using log/invlog, or e^x/ln. Let's me know that i'm not a complete dunce

        I'll paste the function(s) when i finish, will be later tonight.

        Thanks Ganch!
        Originally posted by unusialsusp5
        what an idiotic question about nothing
        And you... if you need your first post of the day, don't do it in my threads...
        and if you don't understand what I am asking... you should just keep your mouth shut.
        Comment
        • Wrecktangle
          SBR MVP
          • 03-01-09
          • 1524

          #5
          Mav, you may want to try logarithmic regression as a transform. It can map your negative to positive Infinity numbers to -1 / +1 which you can then multiply by 100.

          In another direction: is it my imagination or are we suffering more idiots lately in the Tank?
          Comment
          • sharpcat
            Restricted User
            • 12-19-09
            • 4516

            #6
            Originally posted by Wrecktangle
            Mav, you may want to try logarithmic regression as a transform. It can map your negative to positive Infinity numbers to -1 / +1 which you can then multiply by 100.

            In another direction: is it my imagination or are we suffering more idiots lately in the Tank?
            I think the misspelling of "unusual" in the username "unusialsusp5" is a good indicator of one who may be out of his habitat.
            Comment
            • unusialsusp5
              SBR MVP
              • 04-18-10
              • 4198

              #7
              maybe the misspelling was intentional. congratulations on your mathematical expertise. how much money did you waste going to school. i don't believe your astute math knowledge could help you handicap sports out of a paper bag.
              Comment
              • durito
                SBR Posting Legend
                • 07-03-06
                • 13173

                #8
                Originally posted by unusialsusp5
                maybe the misspelling was intentional. congratulations on your mathematical expertise. how much money did you waste going to school. i don't believe your astute math knowledge could help you handicap sports out of a paper bag.
                You'd be very wrong.
                Comment
                • djiddish98
                  SBR Sharp
                  • 11-13-09
                  • 345

                  #9
                  Ha, handicapping without math
                  Comment
                  • unusialsusp5
                    SBR MVP
                    • 04-18-10
                    • 4198

                    #10
                    you probably believe we went to the moon in 1969 too.
                    Comment
                    • Maverick22
                      SBR Wise Guy
                      • 04-10-10
                      • 807

                      #11
                      Originally posted by Wrecktangle
                      Mav, you may want to try logarithmic regression as a transform. It can map your negative to positive Infinity numbers to -1 / +1 which you can then multiply by 100.

                      In another direction: is it my imagination or are we suffering more idiots lately in the Tank?
                      My regression skills are nil... Gonna need someone to handhold me on that

                      But i will see if i can google my way into it.

                      Thanks!
                      Last edited by Maverick22; 07-11-10, 09:08 PM. Reason: Misspelled "nil"
                      Comment
                      • Flying Dutchman
                        SBR MVP
                        • 05-17-09
                        • 2467

                        #12
                        Originally posted by Maverick22
                        My regression skills are nill... Gonna need someone to handhold me on that

                        But i will see if i can google my way into it.

                        Thanks!
                        Maverick, you can do it in Excel. Give me a call or send me the data in e-mail and we'll sort it.

                        Comment
                        • Indecent
                          SBR Wise Guy
                          • 09-08-09
                          • 758

                          #13
                          Originally posted by Ganchrow
                          If you needed a linear transformation and you could specify limits on your domain endpoints (call them a & b) then the mapping of ±x0 ∈ [a, b] → ±y0 ∈ [-100, 100] is just be the line segment with endpoints (-100, a) and (+100, b), which is:
                          F(x) = 100*(a + b - 2x) a - b
                          Wow, I'm embarrassed to share how convoluted my solution to this was.

                          It's always nice to have a one liner replace crappy code, thanks for the reminder to consider the obvious (and easiest!) solution.
                          Comment
                          SBR Contests
                          Collapse
                          Top-Rated US Sportsbooks
                          Collapse
                          Working...