0

I'm trying to create a program which allows the user to enter in any number of values, where each value can be any number. For example, the user may choose to enter the following 4 values:

-478.93
485.44
569.48
593.82

What formula do I need to use to get the slider in the program to show -478.93 when the slider is at the 0% position and 593.82 when the slider is at the 100% position? The slider should show the correct value at all other percentages.

For example, when at the 50% position, it should show 292.4525, which is the average of the values entered in by the user:

292.4525 = ( -478.93 + 485.44 + 569.48 + 593.82 ) / 4
  • I was about to post my answer when you erased last time. – CAGT Jan 07 '14 at 21:10
  • Sorry, I thought the previous question was too long and unclear. Any chance of getting back to your answers text using the browsers back button to copy the text? – oshirowanen Jan 07 '14 at 21:13
  • Unfortunately not, but I still have my spreadsheet data... why now you have a negative value? – CAGT Jan 07 '14 at 21:14
  • I have the negative value to show that the user can type in any value and any number of values too, not just 4 values and not just positive values. – oshirowanen Jan 07 '14 at 21:14
  • Ok, because you assume all data must fit in that range, 50% will not be near 289.20, it will actually be at 57.445 – CAGT Jan 07 '14 at 21:15
  • Sorry, made a mistake. 1 second. – oshirowanen Jan 07 '14 at 21:18
  • I used the following to get that 50% value: 292.4525 = ( -478.93 + 485.44 + 569.48 + 593.82 ) / 4. It's slightly different from what I had their originally. Not sure how I ended up with that 289.20. – oshirowanen Jan 07 '14 at 21:20
  • Ok, if you want a linear response, the 50% mark will not match the average of the samples. – CAGT Jan 07 '14 at 21:25
  • Any other solutions/formulas I can use to achieve my end result? Basically 0% = -478.93, 50% = 292.4525, 100% = 593.82. 50% will be the average of the values entered by the user. All other percentages should act accordingly. – oshirowanen Jan 07 '14 at 21:27
  • 1
    You will need two slopes: one for 0 to 50% and the sencond for 50% to 100%. – CAGT Jan 07 '14 at 21:32
  • +1 for the 2 slope idea. I'll give that a try! Thanks. – oshirowanen Jan 07 '14 at 21:37

1 Answers1

1

Let $a$ be the minimal value (here $a=-478.93$), $c$ the maximal value (here $c=593.82$) and $b$ the average (here $b=292.4525$). Then let the percentage $x$ ($0\le x\le 100$) correspond to

$$ f(x)=\begin{cases}a+\frac x{50}(b-a)&\text{if }0\le x\le 50\\ 2b-c+\frac x{50}(c-b)&\text{if }50\le x\le 100\end{cases}$$ (This corresponds to CAGT's suggestion of two slopes).