# Algorithm to find average position In the given diagram, I have the extreme left and right points, that is -2 and 4 in this case. So, obviously, I can calculate the width which is 6 in this case.

What we know:

The number of partitions:3 in this case The partition number at at any point i.e which one is 1st,second or third partition (numbered starting from left)

What I want:

The position of the purple line drawn which is positio of average of a particular partition

So, basically I just want a generalized formula to calculate position of the average at any point.

• are purple lines odd numbers and red lines even? what's your definition of the purple lines ? why are they different from red ones ? – TomTsagk Aug 24 '14 at 9:50
• How can you have three averages? Averages are obtained by summing the values and dividing by the number of values. Is that not working for this situation? – MichaelHouse Aug 24 '14 at 9:51
• What about (width / partition count) * (partitionNo + 0.5)? – wondra Aug 24 '14 at 10:06
• @TomTsagk: purple lines are the averages of red lines at either ends – Simran kaur Aug 24 '14 at 11:06
• @Byte56: average of the two red lines at either ends is the purple line which I consider the average. – Simran kaur Aug 24 '14 at 11:07

How about: (width/amountPartitions) * partitionNo + (width/amountPartitions/2) + posFirstPartition
(6/3) * 0 + (6/3/2) - 2
1 - 2
-1