Calculating percentage location in a normalized set of data
Posted 29 November 2005 - 09:51 PM
If I have an array of values, with the sum of all value elements equal to 1.0, is there an efficient way to calculate the array index of where x% of the total value sum is before that index, and 100% - x% of the values are after that index? Ideally I will be able to calculate this value within a shader.
The practical use of this is to find the index within a histogram where 90% of all values are below that index, and the other 10% are above. This will allow me to reduce the effects of the top 10% of pixels in some techniques. Thanks in advance for any help you can give!
Posted 29 November 2005 - 11:06 PM
the most obvious way is to sum each value and check when the sum is equal to the percentage you desire. but you want a more efficient solution than that, right?
I'm not a math guru, but depending on whether the data is dynamic or static, one way i could think of is to calculate beforehand some best fit curve and perform integration on the resulting equation. you'd solve the integral for x, given the sum (which would represent the percentage). So if the data is static, you'd do the curve fitting offline. In the shader, it would be a matter of plugging in into the equation. This is probably not practical for dynamic data though.
i'll give it more thought.
Posted 30 November 2005 - 02:25 AM
Posted 30 November 2005 - 05:39 AM
Posted 01 December 2005 - 07:34 PM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users