GenerateIntegers() INTEGERS.length INTEGERS.join( ", " ) sortNumbers( INTEGERS ) SORTED_INTS.join( ", " ) DisplayMedian( SORTED_INTS ) mean( INTEGERS ) median( INTEGERS ) mode( INTEGERS )

What is the arithmetic mean of the following numbers?

INTEGER_LIST

MEAN

To find the mean, add all the numbers and then divide by the number of numbers.

INTEGER_LIST

There are INTEGERS_COUNT numbers.

The mean is \displaystyle fractionSimplification( sum(INTEGERS), INTEGERS_COUNT ).

What is the median of the following numbers?

INTEGER_LIST

MEDIAN

First, order the numbers, giving:

SORTED_LIST

Since we have 2 middle numbers, the median is the mean of those two numbers!

The median is the 'middle' number:

MEDIAN_LIST

The median is \dfrac{SORTED_INTS[ SORTED_INTS.length / 2 - 1 ] + SORTED_INTS[ SORTED_INTS.length / 2 ]}{2}.

So the median is fractionReduce(2 * MEDIAN, 2).

Another way to find the middle number is to draw the numbers on a number line. If a number appears multiple times, count its corresponding dot multiple times.

init({ range: [ [-0.5, 10.5], [-1, 1] ] }); style({ stroke: "#666" }, function() { numberLine( 0, 10, 1 ); }); var freq = {}; var labels = {}; jQuery.each(INTEGERS, function( index, number ) { var count = freq[ number ] = (freq[ number ] || 0) + 1; if ( labels[ number ] ) { labels[ number ].remove(); } if ( count >= 2 ) { labels[ number ] = label( [number, 0.2], "\\scriptsize{" + count + "}", "above", { labelDistance: 0 } ); } else { circle( [number, 0], 5/40, { stroke: "none", fill: "#6495ed" } ); } });

What is the mode of the following numbers?

INTEGER_LIST

MODE

The mode is the most frequent number.

We can draw a histogram to see how many times each number appears.

var freq = {}; var maxFreq = 0; jQuery.each(INTEGERS, function( index, number ) { var count = freq[ number ] = (freq[ number ] || 0) + 1; maxFreq = count > maxFreq ? count : maxFreq; }); init({ range: [ [-0.5, 10.5], [-1, ( maxFreq + 1.5 ) / 2] ] }); style({ stroke: "#666" }, function() { numberLine( 0, 10, 1 ); }); for ( var num in freq ) { for ( var i = 0, l = freq[ num ]; i < l; i++ ) { circle( [num, ( i + 1.5 ) / 2], 5/40, { stroke: "none", fill: "#6495ed" } ); } }

There are more MODEs than any other number, so MODE is the mode.