Formula for median of a set (sorted)

In summary, the conversation discusses finding the median of a set of numerical observations. The formula for calculating the median is to subtract 1 from the number of observations and then divide by 2. The result is then added by 1 to get the median. The conversation also mentions a method for finding the median of a sorted set of observations, taking into account the size of the array. If the size is even, the median is the average of the two middle observations, and if the size is odd, the median is the middle observation.
  • #1
shadowboy13
20
0
Now i think i derived this correctly, but I'm not sure if it's correct, can anyone give me a confirmation?

##n-1/2=x##

Where ##x## is the result of subtracting 1 from the observations and then dividing by 2.

Then ##x+1=Median##

Thank you :)

Edit: Oops, this is the handicapped version of the better formula... figures
 
Physics news on Phys.org
  • #2
If you're writing a method that returns the median of a sorted set of n numerical observations, I'm assuming they are all sorted in an array of size n. If so, you have to check whether the size of the array is an even or odd number. If even, return the arithmetic mean of the middle two observations; if odd, return the middle observation. This might look like:

public double getMedian( data [] list )
{
if( list.length % 2 == 0 )
return ( list[ list.length / 2 ] + list[ ( list.length / 2 ) - 1 ] ) / 2.0;
else
return list[ list.length / 2 ];
}
 

What is the formula for finding the median of a set of numbers?

The formula for finding the median of a set of numbers is (n+1)/2, where n is the number of values in the set.

How do I find the median of a set of numbers that are already sorted?

If the set is already sorted, simply take the middle value as the median. If there is an even number of values, take the average of the two middle values.

Can the median of a set be a decimal or fraction?

Yes, the median can be a decimal or fraction. If the set has an even number of values, the median will be the average of the two middle values, which may result in a decimal or fraction.

What do I do if there is an even number of values and no exact middle value?

If there is an even number of values and no exact middle value, take the average of the two middle values to find the median.

Is the median affected by outliers in the set?

Yes, outliers can affect the median. If there are extreme values in the set, they may pull the median towards them, resulting in a different value than if the outliers were not present.

Similar threads

  • Precalculus Mathematics Homework Help
Replies
4
Views
2K
Replies
3
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
715
  • Engineering and Comp Sci Homework Help
Replies
7
Views
891
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
828
  • Set Theory, Logic, Probability, Statistics
Replies
23
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
1K
  • Programming and Computer Science
Replies
27
Views
2K
Replies
3
Views
1K
  • Programming and Computer Science
Replies
4
Views
2K
Back
Top