Note that there are some explanatory texts on larger screens.

plurals
  1. POAlgorithm to calculate a diminishing value, approaching a limit
    primarykey
    data
    text
    <p>I've been trying to find a Javascript version of a handy method I'd used (not written) a while ago in LPC, it was called dimval(), and it took this form:</p> <pre><code>NAME dimval() - returns values with a reduced increase in output as input values grow larger. SYNOPSIS float dimval(float input, float max_input, float max_output, float min_input, float min_output, float rate); DESCRIPTION Returns (as a float) a value between min_output and max_output, with values increasing at a reduced rate as they move from min_input toward max_output. Input is the input value. Max_input is the maximum acceptable input. Any higher input value will be capped to this. Max_output is the maximum value returned. Min_input is the (optional) minimum input. Default is zero. Min_output is the (optional) minimum output. Default is zero. Rate determines how quickly the cost increases to achieve greater return values. Higher numbers are faster, lower numbers are slower. </code></pre> <p>I <a href="http://lostsouls.org/grimoire_diminishing_returns" rel="nofollow noreferrer">read this article</a>, but it doesn't seem to capture what I want (it looks much simpler for a start). I also <a href="https://stackoverflow.com/questions/2813621/how-do-you-create-a-formula-that-has-diminishing-returns">read this SO question</a> and... well I think this could work... but the Math is beyond me, to be honest. I understand the description above and how the parameters work together to produce the kind of result I want.</p> <p>I'd greatly appreciate it if someone could provide a method which has the above constraints, in Javascript.</p> <p>cheers!</p> <h2>EDIT: Sample outputs from original method.</h2> <ul> <li>eval return dimval(5.0, 100.0, 100.0, 0.0, 0.0, 1.0) => 22.360680</li> <li>eval return dimval(10.0, 100.0, 100.0, 0.0, 0.0, 1.0) => 31.622776</li> <li><p>eval return dimval(50.0, 100.0, 100.0, 0.0, 0.0, 1.0) => 70.710678</p></li> <li><p>eval return dimval(10.0, 100.0, 100.0, 0.0, 0.0, 2.0) => 15.811388</p></li> <li><p>eval return dimval(10.0, 100.0, 100.0, 0.0, 0.0, 10.0) => 3.162278</p></li> <li><p>eval return dimval(200.0, 100.0, 100.0, 0.0, 0.0, 10.0) => 10.000000</p></li> <li><p>eval return dimval(200.0, 100.0, 100.0, 0.0, 0.0, 1.0) => 100.000000</p></li> <li><p>eval return dimval(1.0, 100.0, 100.0, 10.0, 0.0, 10.0) => 0.000000</p></li> </ul> <hr> <p>Let me know if you want me to run any more samples.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload