Finding the percentage of a value within a range

Limey2632

New member
Joined
Jun 19, 2019
Messages
4
Hi folks, I'm new to the forum so I hope I have placed this post in the appropriate spot.

I am doing some programming in a Photoshop script that will display an average value within a range, as seen in image below.
I have a problem with finding a percentage of a value within the range. Below you can see the math that I have been applying but it only appears to work up to a point.
I am not a mathematician by any means and this is baffling me. Initially I was reducing the average value by the minimum value of the range (15.5 - 3 = 12.5). That prevented the overage but messed up lower values ( $6 became $3 and showed as zero on the line).

Is there a way that I can determine the percentage of the average range without going over. I am working on the basis that the distance between the minimum and maximum is 100%. My line is drawn as a percentage.

Any help would be most gratefully appreciated.

Paul

12648
 
15.5 / (34-3) * 100 = 50 ...how did you get 48.39?
Sorry Dennis, I originally used 15 instead of 15.5 because in reality I am rounding. Javascript rounds 15.5 down. That's how I ended up with 48.39.
When I was putting the visual together I forgot to change the result to 50. My bad!
 
I think you want to subtract the bottom of the range from both numbers/ In the second example, you would get (33-3)/(34-3) = 30/31 = 96.77%.

This way, the bottom of the range always yields 0, and the top is always 100%. That's what you want, right?
 
Thank you Dr. Peterson, I tried that. Here is an example using half of the range (31), 15.5 as the "average".
(15.5-3)/(34-3) = 12.5/31 = 40.32% . There in lies my problem with that. What I would expect to show as half way on the range is showing up as about 40%.
 
Thank you Dr. Peterson, I tried that. Here is an example using half of the range (31), 15.5 as the "average".
(15.5-3)/(34-3) = 12.5/31 = 40.32% . There in lies my problem with that. What I would expect to show as half way on the range is showing up as about 40%.
The range is from 3 to 34, right? The midpoint (average of min and max) is (3 + 34)/2 = 18.5. You took half the max instead.

Using 18.5, the percentage becomes (18.5 - 3)/(34 - 3) = 15.5/31 = 50%, as expected.
 
Thank you Dr. Peterson, The issue was how I was perceiving the value of 15.5 on the line. I was looking for it to be in the center because 15.5 is half of 31, the range. The truth is, when you look at it purely numerically, 15.5 is closer to 3 than it is 34. What I thought was a problem was an accurate portrayal of where 15.5 falls between 3 and 34. You are quite right and it helped a lot when you pointed out that 18.5 was half way between the two numbers. Thanks for your help!
 
Top