Khan/khan-exercises

Older
100644 158 lines (150 sloc) 8.05 KB
 c2abb10 Add exercise: Exploring mean and median beneater authored Nov 7, 2011 1 2 3 4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 4 5 Exploring mean and median 6 c2abb10 Add exercise: Exploring mean and median beneater authored Nov 8, 2011 7 8 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 9
10
11 -7 12 -1 * LOWER_BOUND 13 20 random() < 0.8 ? 10 : 5 21 22 roundTo( 1, randRangeNonZero( (LOWER_BOUND + 1) * 2, (UPPER_BOUND - 1) * 2 ) / 2 ) 23 24 25 ((POINTS / 2) * (MEDIAN + 0.5) + MEDIAN - 0.5 + (POINTS / 2 - 1) * LOWER_BOUND) / POINTS 26 27 28 ((POINTS / 2) * (MEDIAN - 0.5) + MEDIAN + 0.5 + (POINTS / 2 - 1) * UPPER_BOUND) / POINTS 29 30 roundTo( 1, randRangeNonZero( MIN_MEAN * 10, MAX_MEAN * 10 ) / 10 ) 31
32
33
34
35

Arrange the POINTS orange points on the number line so the 36 arithmetic mean is MEAN 37 and the median is MEDIAN. 38 The distance between adjacent tick marks is 1.

39
40 graph.targetMedian = MEDIAN; 41 graph.targetMean = MEAN; 42 graph.numPoints = POINTS; c2abb10 Add exercise: Exploring mean and median beneater authored Nov 8, 2011 43 4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 44 init({ 45 range: [ [LOWER_BOUND - 1, UPPER_BOUND + 1], [-3, 3] ] 46 }); c2abb10 Add exercise: Exploring mean and median beneater authored Nov 8, 2011 47 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 48 style({ stroke: "#bbb" }); 49 line( [ LOWER_BOUND, 0 ], [ UPPER_BOUND, 0 ] ); 50 for ( var x = LOWER_BOUND; x <= UPPER_BOUND; x++ ) { 51 line( [ x, -0.2 ], [ x, 0.2 ] ); 52 } 53 style({ strokeWidth: 3.5 }); 54 line( [ 0, -0.2 ], [ 0, 0.2 ] ); 55 label( [ 0, -0.53 ], "0", "center", {}); c2abb10 Add exercise: Exploring mean and median beneater authored Nov 8, 2011 56 4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 57 style({ strokeWidth: 2, stroke: BLUE, fill: BLUE, opacity: 1.0 }); 58 graph.meanArrow = path([ 59 [ 0, 0.7 ], [ 0.05, 0.7 ], [ 0, 0.6 ], [ -0.05, 0.7 ], [ 0, 0.7 ], [ 0, 1.0 ] 60 ]); 61 graph.meanLabel = label( [ 0, 1.3 ], "\\text{mean}", "above", { color: BLUE }); 62 graph.meanValueLabel = label( [ 0, 0.8 ], "0", "above", { color: BLUE }); c2abb10 Add exercise: Exploring mean and median beneater authored Nov 8, 2011 63 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 64 style({ strokeWidth: 2, stroke: GREEN, fill: GREEN }); 65 graph.medianArrow = path([ 66 [ 0, -1.1 ], [ 0.05, -1.1 ], [ 0, -1 ], [ -0.05, -1.1 ], [ 0, -1.1 ], [ 0, -1.4 ] 67 ]); 68 graph.medianLabel = label( [ 0, -1.7 ], "\\text{median}", "below", { color: GREEN }); 69 graph.medianValueLabel = label( [0, -1.2 ], "0", "below", { color: GREEN }); c2abb10 Add exercise: Exploring mean and median beneater authored Nov 8, 2011 70 4e4cb9b lint: tabs->spaces and jQuery->$for exercises beneater authored Apr 10, 2012 71 addMouseLayer(); 72 graph.points = []; 73 for ( var x = 0; x < POINTS; x++ ) { 74 graph.points[x] = addMovablePoint({ 75 coord: [ x - POINTS / 2 + 0.5, 0 ], 76 constraints: { constrainY: true }, 77 snapX: 0.5 78 }); 79 } c2abb10 Add exercise: Exploring mean and median beneater authored Nov 8, 2011 80 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 81 graph.median = 0; 82 graph.mean = 0; 83 graph.moved = false; 84 $.each( graph.points, function( idx, point ) { 85 this.onMove = function( x, y ) { 86 graph.moved = true; 87 return onMovePoint( point, x, y, updateMeanAndMedian ); 88 }; 89 }); 90 91 92 93 94 Move the orange dots to select your answer. 95 96$.map( graph.points, function( el ) { return el.coord[0]; } )
97
98 if ( roundTo( 1, mean( guess ) ) === MEAN && roundTo( 1, median( guess ) ) === MEDIAN ) { 99 return true; 100 } else if ( graph.moved ) { 101 return false; 102 } else { 103 return ""; 104 } 105
106
107 $.each( guess, function( i, x ) { 108 onMovePoint( graph.points[i], x, 0 ); 109 }); 110 updateMeanAndMedian(); 111 112 any arrangement of the orange dots so that the mean and median are correct 113 c2abb10 Add exercise: Exploring mean and median beneater authored Nov 8, 2011 114 4e4cb9b lint: tabs->spaces and jQuery->$ for exercises beneater authored Apr 10, 2012 115
116

117 The median is the middle number. In other words there are always as many points to the 118 right of the median as to the left. 119

120

121 Try dragging the points so that half of them are to the left of 122 MEDIAN 123 and half of them are to the right of 124 MEDIAN. 125 126 The two points in the middle should be the same distance from 127 MEDIAN. 128 129 130 The middle point should be at 131 MEDIAN. 132
133 136

137

138 As long as there are as many points to the left and to the right of the 139 median, the median will stay the same. But the arithmetic mean is calculated 140 using the value of every point. Try moving the points on either side of the 141 median closer and further from the median to see how the mean is affected. 142

143

144 There are a number of different ways to arrange the points so the mean is 145 MEAN 146 and the median is 147 MEDIAN. 148 151

152
153
154
155
c2abb10 Add exercise: Exploring mean and median beneater authored Nov 8, 2011 156 157
Something went wrong with that request. Please try again.