Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9178115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:28:38+00:00 2026-06-17T17:28:38+00:00

I have a thing (details not important) that outputs a number between 0 and

  • 0

I have a “thing” (details not important) that outputs a number between 0 and + infinity. The number is measure of certain input factors where a high number is bad and a low number good.

I need to add to this a sensitivity setting – so the caller can specify a number that essentially scales the output.

Ideally I would like that scale to be between -1 and 1. 0 represents normal. As the scale increases towards 1 the sensitivity increases and the output number decreases. As the scale decreases towards -1 the sensitivity decreases and the output number increases.

So far, I have this:

static decimal GC(decimal inVal, decimal gc)
{
decimal nOUT = inVal;
if( gc > 0 )
{
    nOUT = Math.Max( inVal * (1 - gc), 0 );
}
else if( gc < 0 )
{
    if( gc == 1 ) gc = 0.9M;
    decimal d = Math.Abs(gc);
    nOUT = inVal * ( (1 / d) );
}
return nOUT;
}

GC being my scale function and gc being the input factor.

This works OK for towards 1, with output being

IN = 3.0, OUT = 3.0, gc = 0
IN = 3.0, OUT = 2.7, gc = 0.1
IN = 3.0, OUT = 2.4, gc = 0.2
IN = 3.0, OUT = 2.1, gc = 0.3
IN = 3.0, OUT = 1.8, gc = 0.4
IN = 3.0, OUT = 1.5, gc = 0.5
IN = 3.0, OUT = 1.2, gc = 0.6
IN = 3.0, OUT = 0.9, gc = 0.7
IN = 3.0, OUT = 0.6, gc = 0.8
IN = 3.0, OUT = 0.3, gc = 0.9
IN = 3.0, OUT = 0.0, gc = 1.0

But not for towards -1 without output being

IN = 3.0, OUT = 3.0, gca = 0
IN = 3.0, OUT = 30.0, gca = -0.1
IN = 3.0, OUT = 15.0, gca = -0.2
IN = 3.0, OUT = 10.0, gca = -0.3
IN = 3.0, OUT = 7.5, gca = -0.4
IN = 3.0, OUT = 6.0, gca = -0.5
IN = 3.0, OUT = 5.0, gca = -0.6
IN = 3.0, OUT = 4.3, gca = -0.7
IN = 3.0, OUT = 3.8, gca = -0.8
IN = 3.0, OUT = 3.3, gca = -0.9
IN = 3.0, OUT = 3.0, gca = -1.0

I need the output number to get bigger as gca approaches -1.

The second problem I have with this is one of scale. At most, the number will be 10 times bigger. I think I need to introduce another number, say scale, where gca represents the proportion of scale that is applied +/- to the output number but I dont know how.

Can any one help? Either fixing this or with a better way!
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:28:39+00:00Added an answer on June 17, 2026 at 5:28 pm

    I’m not quite sure I understand your problem correctly, but perhaps this will work?

    else if( gc < 0 )
    {
        nOUT = inVal / (1 + gc);
    }
    

    This expression becomes singular as gc approaches -1, and nOUT diverges toward infinity hyperbolically. This is the natural “opposite” of the 0 < gc < 1 case.

    If you want to limit the number to being 10 times bigger, you could just rescale gc by multiplying by 0.9; this will limit the (1 + gc) term to 0.1, which corresponds to a multiplication by 10. For example:

    gc *= (1 - 1 / 10.0)
    

    Also note that your use of Math.Max in the 0 < gc < 1 case is redundant.


    To give you an idea of how this scaling behaves, here’s a plot I made of nOUT against gc for inVal = 5, with a limiting value of 10:

    Plot of nOUT agains gc

    You should note, however, that imposing this limit on how much larger the number can be makes the scaling asymmetric and less “nice”. For smaller limiting factors than 10, you’ll see a cusp at gc = 0; for example, with a limiting factor of 1.5:

    enter image description here


    Another approach would be to simply cap the scaling factor at 0.9, rather than rescaling the factor itself as I suggested above. This eliminates the cusp at gc = 0 and instead just flattens it off when it reaches that limiting factor (10 in this case). You could achieve this like so:

    gc = Math.Max(gc, -(1 - 1 / 10.0))
    

    And here’s a graph to compare the two methods (blue line is first method; red line is second):

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this thing that i need to do and some advices will be
Details: I have a service that needs to do the following: - listen constantly
I have this thing working mostly. What I don't get is, if I have
I'm reading the documentation now, and I have 1 thing to be fixed -
The thing I have a web app (asp.net) which needs to have a feed.
One thing I have noticed a lot of back and forth on is where
One thing I have continually found very confusing about using an object database like
I have the following thing to achieve in Android(newbie). I have an xml which
I have created following thing in android using android compatibility support package Basically i
Is it a bad thing to have two xml columns in one table? +

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.