Statistics: why the median might sometimes be preferred over the mean

Tutoring statistics, you talk about the median vs the mean.  While the mean is probably used more (because of its involvement in the normal distribution), the median is preferred in some applications….

Back in my May 6 post, I briefly defined the mean and the median. In a student’s first couple of stats courses, the normal distribution (see my post here) is likely to dominate; it centres around the mean. So to a statistics student, the mean is likely the prominent measure of the “centre” of a set of data.

Real estate, however, might favour the median (at least, that’s my impression). I recall hearing the “median house price”, not the mean.

Why might the median be preferred to the mean? Let’s imagine the following numbers are prices of houses for sale in a small town:

Prices (K)

105 175 225 295 325

The list above, conveniently arranged in ascending order, has an obvious median value of 225K. Its mean is also 225K. The mean price and the median price of a house in this imaginary town are both 225K.

Now, let’s imagine the house at $325K sells. At the same time, a local millionaire decides to move, so puts his shack on the market, asking a million five hundred thousand. Let’s look at our new price list:

Prices (K)

105 175 225 295 1500

The median price remains 225K; the middle value in the list hasn’t changed. However, the mean has ballooned to 460K. The mean, of course, is the sum of the prices, divided by how many there are (five, in this case). Since 1500 is much higher than the number it replaced, the sum of the prices has dramatically increased; so, then, must the mean. After all, the number of houses for sale hasn’t changed.

A realtor in that town knows that if you hear its mean house price is 460K, you’re only likely to look at its listings if you’re rich. A first-time or middle-income buyer won’t likely be able to get a mortgage in the neighbourhood of 400K. Ironically, most houses in that town are very reasonably priced; only one in five is above 300K. In fact, first time and middle income buyers should be attracted to the town; the majority of its housing inventory is priced under 250K – distantly below the 460K average value. (Mean is the more refined term for average, from many people’s point of view).

The realtor decides that, in fact, the mean house price of 460K is misleading. While it’s academically true, it sends the message that the town is expensive to buy in. With 60% of its housing inventory below 250K – and 40% even below 200K – the town is actually a very affordable place to seek housing.

The realtor decides that the median house price of 225K reflects much better the affordability of housing in the town. Two houses are more, while two are less. The millionaire’s $1.5 million house won’t be of interest to most buyers, anyway.

The mean is potentially very sensitive to single values that are widely different from the general population. The median, by contrast, is much more stable in the face of atypical values. Therefore, some data consumers prefer the median to the mean.

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Perl: a program to find the median

Tutoring stats, you discuss the median.  The tutor introduces a Perl program that finds it.

I defined the median back in my May 6 post. It’s preferred over the mean in some realms; I’ll explore the reason another time.

Today, we’ll look at a Perl program that finds the median. It’s a great way to jump-start the Perl-programming discussion, as well as show off a couple of Perl’s built-in functions. Here it is:


@lst=sort{$a <=> $b}@ARGV;
#uses Perl’s built-in sort to write the numbers, in ascending order, #into @lst
} #this loop counts the numbers given to the program
if($n%2==0){#if the list has an even number of values
#arrays start at 0, so you need to adjust down one place when #referencing.

else{ #the list has an odd number of values
print “The list you entered is\n\n”;
foreach $one(@ARGV){
print “$one “;
print “\n\n”; #makes space for reading
print “The list in ascending order is\n\n”;
foreach $one(@lst){
print “$one “;
print “\n\n”;
print “The median is $med :)”;
print “\n\n”;

Notice the % on line 9. It’s the modulus operator, and gives the remainder of a division. If you divide by 2 and get a remainder of 0, the number must be even.

This program will serve as a platform from which to launch discussions in future posts. Stay tuned:)


McGrath, Mike. Perl in easy steps. Warwickshire: Computer Step, 2004.

Robert’s Perl Tutorial

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Canadian history: how French rights prevailed in Quebec after 1763

Tutoring social studies, questions come to mind that aren’t necessarily discussed every day.  The tutor focuses on a central question about the Canadian identity.

To a Canadian anglophone, the “other world” of Quebec is intriguing.  Anyone who’s been there knows it’s like a different country.

The French language and culture that exist in Quebec have done so from the 1600s – before English settlement in much of Canada.  Without necessarily knowing the details, most Canadians are conscious that after a conflict between English and French, the English culture came to dominate the rest of the country, while Quebec remains French to this day. So, why is the rest of the country (generally) not French?  How did French prevail in Quebec?

The French began settling what is now Quebec – calling it “New France” –  while the English focused on the Thirteen Colonies (New England).  Life in New France – with its available farmland, its harsh winters, and its absolute necessity of self-reliance – was totally different from what the settlers had left behind in France.  In the fertile land along the St. Lawrence, covered in snow as much as five months a year, a new identity sprouted – the Canadien.  While they still spoke French, the Canadiens perceived themselves as distinct.

From 1756 to 1763, England and France clashed in the Seven Years’ War, which was a worldwide conflict.  By the Treaty of Paris, 1763, England gained possession of New France; its 65 000 French – the Canadiens – became British subjects.  In King George III’s Royal Proclamation of 1763, he stated intention to allow the French language and Catholic religion to continue, while promising, as quickly as possible, an elected assembly to guide an English government.  New France became the Quebec Colony.

The Quebec Colony’s first governor was James Murray.  He perceived that the elected Assembly – which, possibly, the majority French would be barred from – could put the Quebec Colony under the control of a tiny English minority.  Murray sensed the potential problems that might result. Furthermore, he came to doubt the intentions of the English merchants as they grew impatient for the Assembly’s formation.  In fact, the English merchants eventually petitioned Britain for Murray’s recall, and won – though in England, his side was upheld.

As Governor of Quebec, Murray had come to prefer the peaceful, law-abiding Canadiens over the critical, demanding English merchants.  His replacement, Governor Guy Carleton, took Murray’s side:  The French would never assimilate to English culture – but why should they?   The Candiens were content, hard-working people who were easy to govern.  Carleton petitioned Britain for more protection for the Canadien way of life – and won.  In 1774, the Quebec Act recognized the Canadiens as having distinct status within the British Empire (Bowers and Garrod).  It protected their Roman Catholic religion, their French language, and even their civil laws.  Officially, the Canadien identity was upheld – 93 years before the country Canada even existed.

So, perhaps ironically, two Englishmen safeguarded the French Canadian – the Canadien – identity.  Morevover, they did so against the wishes of their English-speaking subjects.  We know they were motivated by a preference they both developed towards the Canadien over the English merchant.

Probably, what prevailed above all, was the British resistance to change.  Both James Murray and Guy Carleton saw the Canadien way of life as entrenched and self-sustaining.  The English merchants, in contrast, wanted to change life in the Quebec Colony – and expected royal assistance to do so.  Both Murray and Carleton, while they must have realized change would come in some form, believed it had to be spontaneous in order to be valid.  In the meantime, no change at all was fine with them.


Bowers, Vivien and Stan Garrod.  Our Land:  Building the West. Toronto:  Gage, 1987.

k-12 social studies foundation, Manitoba

Thank-you to all my sources for this article:)

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Linear algebra: more on determinants

Following up on yesterday’s post, the tutor continues about determinants. Tutoring university math or natural sciences, they come up often.

Yesterday’s post covered some basics about determinants including a 2×2 and a 3×3 example.  Although it revealed the necessities for many practical situations, it left out most of the theory.  However, determinants are a playground for mathematicians; covering all the theory about them in a dozen posts would still be impossible.

We face the following question:  are there little bits of extra theory that could really help a student with determinants?  Are there little observations that could ease a student’s uptake of the topic?

Today:  one observation and one bit of theory:

Observation 1:  When a matrix is shown in vertical brackets rather than square ones, it usually means the determinant of the matrix.

That is, if you have matrix A:


Theoretical point 1:

You can expand the determinant along any row or column. In yesterday’s example, I showed how to evaluate the determinant of B

from the top row. However, you could evaluate det B from the middle column instead. For the negative flip-flopping, remember to multiply each step by (-1)^(r+c), where r is the row, and c is the column.

I’ll now evaluate det B from the middle column (using the procedure from my previous post):

The middle column starts at 11, which is in row 1, column 2. Therefore, the “flip-flop” factor will be (-1)^(1+2)=-1. Imagining the matrix without the first row and second column, we proceed:


We move to the next number in the second column: the 2. Its flip-flop factor is (-1)^(2+2)=1:

1×2(3*5 – (-1)(1))=2(16)=32

Now, we arrive at the third member of the middle column, which is a 0. Here we get a break: 0 times anything else is 0.

Finally, we add our results:

det B=-143+32+0=-111

So, det B comes to -111, just as it did from yesterday’s expansion along the top row.

Having the freedom to choose the row or column to expand from is definitely an advantage when evaluating the determinant, since you can make convenient use of zeros in a matrix.

I hope this helps all you college/university students, for whom first term exams draw near:)

Source: Johnson|Riess|Arnold. Introduction to Linear Algebra, 2nd Edition. Don Mills, Ontario: 1989.

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Linear algebra: how to evaluate a determinant

Tutoring college math, you cover determinants.  They are used in calculus, differential equations, and physics – just to name a few contexts.  However, they belong to linear algebra.  The tutor works a couple of examples.

The determinant is a number that arises from a matrix.  Consider the following example:

Example 1: Evaluate the determinant of matrx A:


Multiply the numbers along the diagonal from top left to bottom right. Take that result, then subtract from it the product of the other diagonal:

det A = -2*-9 – 3*4 = 18-12=6

That’s fine – but what about a larger matrix? In fact, 3×3 matrices are probably the most common ones on which to evaluate the determinant. How do you do it, in that case?

Example 2: Find the determinant of matrix B:


There are many ways to do this; here might be the most common:

Start at the top left. Imagine the square 2×2 matrix that results by omitting the first row and column (let’s call it matrix P). Multiply the top left number by det P:

3(2*5 – 0*(-7)) = 30

Continue with the top middle number in B: the 11. Now imagine the 2×2 matrix you get by omitting the top row and middle column. Do it the same as before, except you multiply it by -1 (the process flipflops between 1 and -1):

-1(11)(4*5 – (-1)(-7))= -11(13)=-143

Next step: repeat the process, this time from the top right number. The -1 from last step flip-flops back to 1. We proceed as follows:

1(4*0 – (-1)(2))=2

Finally, we take our three results from above and add them together:

30 – 143 + 2 = -111

So, the determinant of matrix B, above, is -111.

There is much to discuss about determinants. I’ll be saying much more about them in future posts:)


Johnson/Riess/Arnold: Introduction to Linear Algebra. Don Mills: Addison-Wesley, 1989.

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Calculus: how to use the product rule

Tutoring calculus, this might be the first derivative rule you need to emphasize. The tutor opens up the discussion….

The product rule is not the first derivative rule people learn, but it might be the first non-intuitive one.  The other candidate might be the chain rule, which I’ll cover in another post.

I confess that when I first saw the product rule, I wanted to doubt it.  While I agreed it must be true, it seemed to lack the elegance I expected from calculus. That was at the start of my degree, of course; a year later, I’d gotten used to it.

By itself, the product rule is useful.  Moreover, several elegant techniques in later courses are based on it.

The product rule is used to find the derivative of a product of functions; ie, two functions multiplied together.  One statement of it is


Let’s look at an example:

Find the derivative: (x^2-3)sinx


We first need to identify the functions u and v that make the product. In this case, it seems obvious enough to decide



Then, following the product rule,


Now we take the separate derivatives as indicated:

((x^2-3)sinx)’=(x^2-3)cosx + (2x)sinx

We expand:

((x^2-3)sinx)’=x^2cosx -3cosx + 2xsinx

So, it turns out, by the product rule, that the derivative of (x^2-3)sinx is x^2cosx -3cosx +2xsinx.

Really, the product rule is kind of appealing, if you give it a chance:)

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Math: simplifying a fifth root

Tutoring high school math, radicals are prominent.  The tutor offers an example of simplifying a higher radical.

I’ve written a number of articles on simplifying radicals. I won’t encumber this one with a list of the previous ones, but you can find them by searching for “radical” or “root” in the search box.

Today, we’ll look at this example. (Note that the fifth root is the same as the exponent 1/5.)

Simplify (-486)^(1/5)

Note that you can simplify odd roots of negatives, just not even ones.

If you try to take the fifth root of -486 on your calculator, you’ll get a messy decimal, which is not acceptable as simplified form. Therefore, a perfect fifth power number must lurk inside -486; the job is to find it.

We start by listing perfect fifth powers:


Clearly, 4^5 is much too large to fit in -486; therefore, our number must be either 32 or 243. 32 looks tempting, by if you try -486/32 you get a decimal. However,



(-486)^(1/5) = (-243)^(1/5)*(2)^(1/5) = -3*(2)^(1/5)

When simplifying an odd root of a negative, always take the negative out front:)

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Electronics: how a transistor works

Tutoring science, you are naturally interested in technology.  The tutor begins an exploration of electronics.

A transistor is a device that can be used to control current flow.  Perhaps its most recognizable application is in amplifier circuits.  In that context, very small current fluctuations received by the transistor lead to very large fluctuations in its output.

A transistor’s ability to amplify current arises of its chemical composition.  It contains three “layers”:  the collector, base, and emitter.

The collector and emitter are normally rich in current carrying species, while the base is poor.  With no current to the base, it essentially “insulates” the collector from the emitter.  No current can flow across the transistor in that case.

When the base is supplied with current, it becomes conductive between the collector and the emitter.  Now, current can flow from the collector, through the base, and out the emitter.  The circuit becomes “live”.

The conductivity of the base can be described as its “gain”; this term means the amount of output current that can be expected relative to current entering the base.  The gain is typically from 50 to 200, or even more, depending on the transistor – of which there are thousands of models.  Obviously, with a gain of 150, you’ll get 150 mA out the emitter for 1 mA in the base.  This example illustrates the amplifying ability of a transistor.  Of course, they can be used in sequence to achieve any gain required.

While the explanation given above is a simplification, it is essentially correct.  I have left out some terms and complications, for now, that I will discuss in coming posts:)

Source: Wikipedia

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Calculus: Finding the derivative with the CASIO fx-991ES

With exams looming, people might come to tutoring with questions about their calculators:  What does it do (besides the obvious)?  How can it really help me? The tutor offers a handy hint about the CASIO fx-991ES.

Some exams don’t allow the use of just any calculator.  Make sure, as a student, you know which one(s) you can use.  If you need to buy a different one for the exam, pick it up as soon as you can:  familiarity with your calculator is key.

For those allowed to use the CASIO fx-991ES, its derivative function might be useful. As far as I can see (and would expect anyway), it doesn’t seem to do symbolic derivatives, but will find the value of the derivative at a specific x value.


Find the value of

d/dx (x^0.5-1)/(sinx +2), x=5

Even those who can confidently evaluate this derivative are likely not excited about doing it.

Well, here’s how to have the CASIO fx-991ES do it for you:

  1. I was in MATH mode when I did this. (That’s shift setup 1).
  2. Press shift∫. Enter the derivative expression: (√x-1)/(sin(x)+2) (Note: it autobrackets with sin.) Use the arrows at left and right of the replay to move around as needed;eg, to get out of the radical sign.
  3. After your expression is entered, arrow over to x= and enter your desired value at which to evaluate the derivative. (x=5, in this case).
  4. Press =. The screen may go blank for a few seconds while the calculator computes the answer. Then, you should be greeted with a restatement of the expression and the answer across the bottom: -0.1087192572, in this case.

I don’t have to explain to calculus students how convenient this function can be:)

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.

Perl: getting input from the user with STDIN

Tutoring, you often straddle a couple of generations.  The tutor reaches back to an old programming tradition….

When I was a kid in the early 80s, computers were very new to have around.  To make them more appealing to the home market – where they were suddenly available and even affordable – computers were given programs that allowed them to interact with the user.  You’d see such situations as this:

Computer screen:  Hello!  What’s your name?

The user would type in: Gerald

Now the computer would reply:

Hello, Gerald! I’m so glad to meet you!

How did our predecessors manage that feat – and how can we do the same?

In Perl, you can do the following:

print “Hello. What is your name?\n\n”;
chop $usrname;
print “\nHello, $usrname! I’m so glad to meet you!”;

<STDIN> means for the computer to gather input from the standard source; ie, the console.

Chop removes the newline (the ENTER stroke) Gerald pressed to “enter” his name.

Part of tutoring is continuing traditions:)

Source: Robert’s Perl Tutorial

Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.