Greetings Monks,
I can't seem to find a way to determine the key of an array which is closest to a value. My data is essentially a bell shaped curve that I will eventually want to do some math on. I am trying to create a simple "full width at half max" type analysis. I am able to easily locate the maximum value and associated key in the hash, but what I am getting stuck on is how to determine the keys (one on each side of max) at which has a value closest to $hash{$max/2}.
My hash has the following values (sorted to make it easier to look at):
Step1: max value (302) has a key of "-2.4".-4 => 0 -3.9 => 0 -3.8 => 0 -3.7 => 1 -3.6 => 0 -3.5 => 1 -3.4 => 0 -3.3 => 0 -3.2 => 5 -3.1 => 19 -3 => 23 -2.9 => 50 -2.8 => 43 -2.7 => 28 -2.6 => 72 -2.5 => 165 -2.4 => 302 -2.3 => 168 -2.2 => 260 -2.1 => 151 -2 => 13 -1.9 => 1 -1.8 => 0 -1.7 => 0 -1.6 => 0 -1.5 => 0 -1.4 => 0 -1.3 => 0 -1.2 => 0 -1.1 => 0 -1 => 0
In reply to Finding hash key related to closest value by nanophd
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |