Weighting on position within a range of numbers

81 Views Asked by At

Firstly, hello all. I'm normally to be found on StackOverflow but felt that this forum was more appropriate for my question. Count this is a coffee break teaser, rather than a fully challenging maths problem and have fun with it!

Hopefully I can explain this clearly.

The problem

I am trying to establish a weighting for the position of a number within a variable range of elements. The actual element numbers don't matter themeselves, purely their place in the order that they are presented. for example, given the range.

1, 9, 2, 4

the number 9 in simple terms would have a weighting of 0.5 due to my very simple calculation of position/number of items. This of course works great if all my ranges are only comprised 4 items. Things get tricky when for example, I want to derive a weighting for the next range of elements:

1, 46, 2, 9, 23, 4, 5, 56

In this example, the number 9 STILL has a weighting of 0.5 as it conforms to the same equation. What I'd like to achieve is a weighting that signifies the fact that the length of the range is greater and therefore being in the middle (or any other arbitary position) has a radically different index due to the range length etc.

The reason

The rationale behind this is that I'd like to determine an index value for a horse in a race based on its position in a given bookies odds ranking. Therefore, in a field of 20 runners, the horse at position 10 would in theory have the 0.5 index value. However, in a field of 4 runners, the horse ranked #2 (index 0.5) has a far greater chance of winning than the 10th runner of 20. Applying a simple 1 in 20 chance for each runner won't cut it as the ranking is derived from form factors and other shenanigans.

Is there a simple way to represent this requirement? (btw - please feel free to edit the tags, I wasn't 100% certain where my question lay)