0
\$\begingroup\$

enter image description here

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.

\$\endgroup\$
  • \$\begingroup\$ are purple lines odd numbers and red lines even? what's your definition of the purple lines ? why are they different from red ones ? \$\endgroup\$ – TomTsagk Aug 24 '14 at 9:50
  • \$\begingroup\$ 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? \$\endgroup\$ – MichaelHouse Aug 24 '14 at 9:51
  • \$\begingroup\$ What about (width / partition count) * (partitionNo + 0.5)? \$\endgroup\$ – wondra Aug 24 '14 at 10:06
  • \$\begingroup\$ @TomTsagk: purple lines are the averages of red lines at either ends \$\endgroup\$ – Simran kaur Aug 24 '14 at 11:06
  • \$\begingroup\$ @Byte56: average of the two red lines at either ends is the purple line which I consider the average. \$\endgroup\$ – Simran kaur Aug 24 '14 at 11:07
1
\$\begingroup\$

How about: (width/amountPartitions) * partitionNo + (width/amountPartitions/2) + posFirstPartition

So for your example for the first partition (counting from 0) this would be:
(6/3) * 0 + (6/3/2) - 2
1 - 2
-1
Which should be what you indicated in your picture.

This is assuming all partitions are the same size.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.