Sage Interact: the Birthday Problem

BirthdayProbThe Birthday Problem asks the question:  In a group of n people, what's the probability that at least 2 will have the same birthday?

Answering the Birthday Problem involves creating a mathematical model. The model rests on two assumptions that aren't true and should be discussed with the class:

  • there are 365 days in a year (Feb 29th is ignored to simplify the model)
  • birthdays are equally likely to be on any given day (Also false. This varies from country to country; in the US birthdays are more towards the middle of the year. Count back 9 months and you've got cold weather. Nothing random there.)

Under those assumptions the sample space is 365^n, since there are 365 choices for each birthday. Counting the number of ways that nobody has the same birthday is just (365)(364)....(365-n+1), giving us the probability of at least 2 people with the same birthday as the complementary probability: 1-[(365)(364)....(365-n+1)]/(365)^n$.

This simple model yields surprising answers: with a group of only 50 people the probability of at least 2 people with the same birthday is 0.97; this illustrates how counter-intuitive probability can be. So is the model any good? It turns out that although the model is built on incorrect assumptions, experimental evidence validates gives results that are close to the model. That's a basic fact about models; they're based on assumptions that in many cases aren't true. Ultimately, experimental evidence is needed to determine whether the model is accurate. Try the Birthday Problem with each of your classes and find out how well it works with 1 class, with any 2 classes, any 3 classes, and so on.

I've created code for computing the Birthday Problem given n people and plots the probabilities on a graph. You can see the output above; the code is on the Python/Sage page.

Some stories that caught my eye recently:

  1. Education Next has articles on "Rethinking the High School Diploma". Three articles consider the idea of having 2 diplomas: 1 for graduating and the second higher diploma for excellence/mastery. It seems symptomatic of today's culture. You can't enforce standards so everybody needs to graduate and the diploma lacks value. So create a second diploma which will show the employer the student has mastered the basics. An interesting idea.
  2. Businessweek has an article suggesting that the US should station soldiers in schools, similar to air marshalls on a plane. The Call of Duty author has, "...anticipated objections. “The public won’t like it, they’ll think it’s a police state,” he said. But, he went on, “All of these are solvable problems.” Anthony’s address, which was punctuated by videos depicting such future threats as a U.S. drone hacked by Iran and a hotel massacre in Las Vegas, included repeated exhortations to policymakers to learn from the examples of corporations and creative artists in selling potentially unpopular ideas. “When we have a new product that has elements that we’re not sure how people will respond to, what do we do as a corporation?” he asked. “We market it, and we market it as much as we can—so that whether people like it or not, we do all the things we can to essentially brainwash people into liking it before it actually comes out.”". Incredible.....
  3. Huffington Post reports on teachers behaving badly: "Louisiana Teachers Planned Illicit Group Sex With Student: Police". The article states, "Police now say that one of the Louisiana high school teachers accused of having group sex with another teacher and a 16-year-old student had previous sexual encounters with the minor.". There's a video from Huffington Post.

Sagetex: derivative as a limit

LimDQI've added another problem to the Sagetex: Limits page. Find the derivative of quadratic function using the limit of a difference quotient. The screenshot is above.

Several stories caught my eye recently:

  1. William Stein, the driving force behind Sage, reports on a, "major 3d update. Print worksheets with embedded 3d graphics. Pan with alt/command. Plots persist between refreshes.". More details can be found here.
  2. The Washington Post has a piece about an "award winning" principal who used to support Common Core and is now opposed to it. She writes about the "Four Common Core 'Flim-Flams'".
  3. Common Dreams reports: "Hundreds of students from high schools across Colorado's Jefferson County school district walked out of classes on Monday, Tuesday, and Wednesday this week, protesting attempts by rightwing members of the school board to amp up what they consider the "positive aspects of the United States and its heritage" within the district's history curriculum while minimizing focus on more progressive aspects of history such as people's movements, the history of struggle, and "social strife."". The article says, "that plan would look at Advanced Placement history courses to make sure materials "promote citizenship, patriotism, essentials and benefits of the free-market system, respect for authority and respect for individual rights" and don't "encourage or condone civil disorder, social strife or disregard of the law."" A passage from a piece on the Breitbart website gives a student opining, "...the nation's foundation was built on civil protest, "and everything that we've done is what allowed us to be at this point today. And if you take that from us, you take away everything that America was built off of."".
  4. This hasn't gotten much publicity: reports, "A secret program to monitor students' online activities began quietly in Huntsville schools, following a phone call from the NSA, school officials say.". According to the school officials they were alerted to a student making threats on Facebook. "The NSA, a U.S. agency responsible for foreign intelligence, this week said it has no record of a call to Huntsville and does not make calls to school systems.". So now Huntsville City Schools are looking at social media sites for gangs, guns, and threats of violence. One school official says, ""There was a foreign connection," said Wardynski, explaining why the NSA would contact Huntsville schools. He said the student in Huntsville had made the online threats while chatting online with a group that included an individual in Yemen.". But it's not just Huntsville. The article continues, "A company called Geo Listening watches social media for school districts including Glendale, Calif. Their web site reads: "Geo Listening's unique monitoring service will process, analyze and report the adverse social media from publicly available student posts... We align our reporting criteria with existing school district procedures and board policy as they relate to student conduct & safety."".

Sagetex: Dartboards and tree diagrams

CombDartsI've added another problem to the Sagetex: Combinatorics/Probability page: "Three darts are thrown at the dartboard. A score is given for each region where the dart lands and the total score is just the sum of the $3$ dart scores. Assume all three darts hit the dartboard. How many different total scores are there? Enumerate them with by drawing a tree diagram."

It's a problem that's illustrates how a tree diagram can be used to organize the solution in a way that anyone can easily check the answer. Typesetting the tree diagram made this a a time consuming problem to create. But the work is done now and the code can be downloaded for you convenience.

Here are some stories that caught my eye recently:

  • Ben Swann alerts us to a "zero tolerance" policy to the extreme.  In Teen Suspended After School Claims Notebook is "Drug Possession" we learn "...a teenager was punished with a lengthy suspension after teachers discovered her folder which contained stories with references to marijuana use." . Her suspension of 10 days was for "...“possession of a controlled substance” despite no drug testing and no drugs in Krystal’s possession". Her written account is considered  possession, apparently, "...although the district’s drug policy posted online provides no specific definition of paraphernalia".
  • CBS San Francisco reports on how outrageous high school behaviour is having an impact: "A Taco Bell restaurant in Antioch has started closing its dining room in the afternoons after managers say it has become a magnet for high school students after class, and fights have been breaking out.“At school you get suspended or something for that, and if you’re not at school you go to the plaza and fight and get away with it,” one student said.". That even includes death threats. Check out the video.

Sagetex: Area under a quadratic using limits

LimAreaI've added another problem to the Sagetex: Limits page. The problem is to find the area under a quadratic using limits. The problem is easy to formulate but explaining the solution is tedious programming. You can see a screenshot of the problem above.

The fourth round of the Chess Masters Final is in the books. Anand has sole possession of first place. The scoring in the event is 3 points for a win, 1 point for a draw. With 2 rounds left and a 4 point lead this tournament is over from a practical standpoint if not a mathematical one. You can follow the games from the site, ChessBomb (on the sidebar) as well as Livestream.

Common Dreams has more on the militarization of the school system: it's even more extensive than you think. From the link: "Turns out San Diego isn't the only school district in the country to get a $700,000 Mine-Resistant Ambush-Protected Armored Vehicle and other military baubles from a federal government overloaded with shiny lethal gimcrackery from its many failed wars. At least 120 schools and colleges in 33 states, including Florida, Georgia, Kansas, Michigan, Nevada and Utah, have gotten such geegaws, according to tenacious reporting by Muckrock and others. Texas - including the town of Cut and Shoot, population 1,000 - tops the list, with at least ten districts gleefully acquiring 15 surplus military vehicles, 64 M-16 rifles, 18 M-14 rifles, 25 automatic pistols, extended magazines, 4,500 rounds of ammunition, armored plating and tactical vests.". ZeroHedge has some quotes from the Wall Street Journal talking about how the Los Angeles Unified School District has gotten "... grenade launchers, M16 rifles and even a multi-ton armored vehicle from the program. But the district is getting rid of the grenade launchers, ".One consequence of spread of weapons is some weapons have been lost, stolen, or otherwise accounted for: "Nine California law enforcement agencies are suspended from the 1033 program, according to Cal OES. The suspensions all stem from lost weapons, including one pistol, 10 M16 assault rifles and one M14 rifle.

The San Mateo Sheriff’s Office has received 78 assault rifles and a truck through the program.  More than 7,700 M16s have been distributed  in California since 2006. In just the last two years, California agencies have also received 41 mine-resistant vehicles."

Next, with all the pressure to get technology into the school system, it's interesting to see the New York Times running an article ("Steve Jobs was a Low-Tech Parent") about how Steve Jobs and various tech CEOs having strict rules regarding the usage of technology in their own family: "...I’ve met a number of technology chief executives and venture capitalists who say similar things: they strictly limit their children’s screen time, often banning all gadgets on school nights, and allocating ascetic time limits on weekends."

Finally, the Daily Caller takes Bill Gates to task on pushing the Common Core onto YOUR kids, but not his. Given the increasingly political nature of Common Core, I think you're going to hear about this in the future.



Graphics: relationship between floor and ceiling functions

FloorCeilingI've added a PDF version of the picture above to the Graphics page and if you're like most people, it needs an explanation. The curriculum I'm covering, along with the supporting book, talks only about the greatest integer function which is denoted by the book as \llbracket x \rrbracket. I find that annoying for several reasons. First, it isn't that clear from the name what the function does. Wikipedia mention that a similar looking symbol was used by Gauss and was the standard until the floor and ceiling functions were introduced in 1962. Secondly, the notation doesn't give any indication what the function does. So when you follow the book all sorts of needless confusion follows because the notation and naming aren't really intuitive. Compare that with the floor and ceiling functions with notation \lfloor x \rfloor and \lceil x \rceil. The little "feet" at the bottom of the floor function are suggestive of rounding the values down and the "feet" at the top of the ceiling function suggest rounding the values up. The floor function is the one that occurs most naturally in the curriculum, such as in determining the number of integers less than 1,000,000 that are divisible by either 5 or 2 (using the inclusion/exclusion) but learning about just the greatest integer function causes confusion because the students aren't sure (poor naming) about how to plot it combined with where is the open circle and where is the closed circle. Students should learn about the floor and ceiling functions at the same time.

The diagram helps to make sense of the floor function and ceiling function and the relationship between them and the line y=x. All three functions have been plotted together and from that diagram you can see:

  1. \lfloor x \rfloor=\lceil x \rceil if and only if x is an integer.
  2. \lfloor x \rfloor=x if and only if x is an integer and \lceil x \rceil=x if and only if x is an integer.
  3. when n is an integer then the intervals (n,n+1) have the ceiling function above the floor function; in fact, \lceil x \rceil-\lfloor x \rfloor =1.
  4. By visualizing the graph (or using y=x as a guide) the student can construct floor and ceiling function more easily and will remember which sides gets the open and closed circles.

The drawback in changing the notation and introducing the more standard notation are students complaining that the book doesn't cover the material so they shouldn't be responsible for it. Teaching to US students has been quite an experience. It would be great if the makers of math textbooks would teach floor functions and ceiling functions rather than the greatest integer function. Half a century behind--time to change! It will make the material easier to learn and take away student excuses.

Odds and Ends: August 6, 2014

DivisorsOfNSeveral odds and ends to mention:

  1. I've added another problem to the Sagetex: Combinatorics/Probability page.  The problem has students determine all the divisors of number. The problem has also been added to the Problems page.
  2. The NY Times has a good article: Why Do Americans Stink at Math?" and it's focus is not what you might expect from the title. One of Japan's most famous math teachers who, "once attracting 1,000 observers to a public lesson" goes to the United States to learn more about the best methods for teaching math only to find that, "The Americans might have invented the world’s best methods for teaching math to children, but it was difficult to find anyone actually using them."
  3. A judge dismisses a lawsuit filed by a teacher who was fired for critical comments she made on her blog about her math class. The judge, "...ruled that the defendants were within their rights to conclude that the teacher's posts 'would erode the necessary trust and respect between Munroe and her students.' ".

Statistics isn't really math

Several months ago I was reminded of how old I was. In a discussion involving numerous teachers I casually stated that "...statistics isn't really math" and the result was confusion. I quickly clarified to my position to say that although theoretical statistics is math (just analysis) a lot of the application (confidence intervals, regression, data analysis) isn't. That distinction didn't clear up the confusion. With time to think about the conversation I think it's a generational issue. The fact is I never had statistics in high school while in college the course wasn't required to major in mathematics (so I didn't take it). It wasn't until I was in graduate school that I had to take statistics and the closely related EDA (exploratory data analysis). Nowadays, however, statistics is a required part of the mathematical curriculum at the high school level so it's not so surprising that my younger colleagues have identified statistics as mathematics--they've been forced to study it in math class.

But just because statistics has a lot of mathematical calculations doesn't mean it's math. Engineering, physics, mathematical economics, and many other courses rely on mathematics yet they aren't called mathematics. You can see some of that distinction is recognized f you look at the departments of many universities. Bigger universities (such as Berkeley or Texas A&M) have a statistics department which is separate from the math department (much like engineering would be a separate department). Other schools (such as here or here or here) have a department of mathematics AND statistics; they specifically differentiate between the two subjects.

Even many people well versed in statistics/EDA recognize the difference; my EDA professor was quite vocal in telling us that EDA was more of an art than a science. He emphasized that no set of statistical measures (mean/median/mode/std/...) could do a better job at determining whether data was normally distributed than he could do by judging normal probability plots with his eyes. The behavior "in the tails" was particularly important.

There are other statistical experts who feel the same. In addition to W.M. Briggs (see his explanation of confidence intervals, regression, p-values) look at the work of statisticians George W. Cobb and David S. Moore who published among, among other articles, "Statistics and Mathematics: Tension and Cooperation". The American Mathematical Monthly 107 (7): 615–630 and "Mathematics, Statistics, and Teaching"
George W. Cobb; David S. Moore, The American Mathematical Monthly, Vol. 104, No. 9. (Nov., 1997), pp. 801-823. These articles and others can give you a more in depth, nuanced view (with plenty of examples) on why statisticians think statistics isn't math. 

AMSTAT NEWS gives a quick summary:

Statistics, however, is not a subfield of mathematics. Like economics and physics, statistics uses mathematics in essential ways, “but has origins, subject matter, foundational questions, and standards that are distinct from those of mathematics” (Moore, 1988, p. 3). David Moore, statistics educator and former president of the American Statistical Association, gives the following four compelling reasons why statistics is a separate discipline from mathematics:

  • Statistics does not originate within mathematics
  • The aims and foundational controversies of statistics are unrelated to those of mathematics
  • The standards of excellence in statistics differ from those of mathematics
  • Statistics does not participate in the inter-relationships among subfields that characterize contemporary mathematics

Besides my simplistic observations that math gives exact answers while statistics will give you confidence intervals for the answer or that EDA can have multiple regression models for the data set (there isn't 1 correct model) you'll also find that people practicing statistics often get the wrong answer. The older crowd might remember "A Random Walk Down Wall Street"; the financial industry used the normal distribution for decades to model risk in the market. With decades of data showing the black swan events occur much more frequently than the normal distribution would predict, its been abandoned for "fat tailed" distributions. That doesn't sound like mathematics, does it?

Statistics is important, but it isn't really math and the spread of statistics into the math curriculum is deluding people that it is. The thinking process, as explained in the links above, is much different than the mathematical thinking process, so pushing statistics into math class is at odds with students learn the mathematical thinking process. As WM Briggs says, "Equations become a scapegoat: when what was supposed to have been true or likely because of statistical calculation turns out to be false and even ridiculous, the culprits who touted the falsity point the finger of blame at the math.....Much nonsense in the last century has been promulgated because of sloppy thinking in statistics. It is time to stop thinking about the mathematics and more on the meaning.". If we want students to get better at math we should stop the spread of statistics into math classes and replace it with math. Discrete math would be the natural candidate as it has applications to computer science.




Sagetex: Combinatorics 10/11

Comb10I've added 2 problems to the Sagetex: Combinatorics/Statistics page.

Problem Type 10: Suppose a system has 6 independent components, each of which is equally likely to work. Now suppose the system works if and only 5 components work. What is the probability the system works?

In problem type 10 the number of independent components is random. Problem Type 11 has students calculate C(n,k) and P(n,k) for random n, k.

Sagetex: Random Bipartite Graphs

RandBiSummer's here and I've had the luxury to just play around. I try to put extra math into the curriculum through either warm up problems, extra credit problems, or examples in the  curriculum that I follow. Discrete math figures prominently in the extra math. In my opinion, discrete math deserves a prominent place in the high school curriculum; it certainly deserves a bigger share of the curriculum. But in a top down system you can't add extra material to the curriculum that the average math teacher has never seen and expect it to be implemented properly.

Graph theory is ideal because it requires little mathematical background to understand and solve problems yet it also provides a way to introduce theorems (many of a basic nature that high school students can understand) along with counterexamples thereby providing a basic primer into the sort of considerations that mathematicians are looking at. In the past, geometry had been the topic for introducing proofs but it's dry as dust and now common core has ripped out much of the proof content so that your typical student can go through math and with very limited exposure to theorems/proofs/counterexamples.

Graph theory would be a way to get that back in a way that is much more interesting than the dry "2 parallel lines are cut by a transversal" proofs that have bored generation after generation. You can even connect to matrices through the adjacency matrix of a graph. Topics like recurrence relations and generating functions complement the curriculum of calculus (power series) and probability. Unfortunately, common core has de-emphasized proofs and matrices and upped the exposure to statistics, so I think it's my duty to undue the damage of the curriculum.

Which brings us back to the current post. Bipartite graphs which have the same number of vertices in each partite set provide a way of determining whether a suitable job can be found for each person so that everyone has a job (see the "Matching" section for the link above). One partite set with vertices, say, A,B,C,D have edges to the other partite set of vertices (a,b,c,d) representing jobs based on whether the person is qualified to do the job. The question becomes, Is there an assignment of jobs so that everyone has a job they're qualified to do? If yes, then there is a (perfect) matching for the graph. If no then there needs to be an explanation as to why no such assignment is possible (Hall's Marriage Theorem).

As a teacher the problem I usually face is finding lots of examples that can be used in the classroom or on a test/quiz. Sage/sagetex is the tool that works best for me. The code generates bipartite graphs so that the number of vertices in each partite set is equal and the probability of an edge being selected for the picture is 1/2.  The code is posted on the Graphics page along with sample output (the PDF shown above). The number of vertices is a random number set between 4 and 8 here: N = Integer(randint(4,8)). The probability of the edge being chosen is set here: if Integer(randint(0,1))==1:

It would be relatively simple to choose a larger number than 1, such as 9, and draw the edge if the number chosen is between 0 and 7 but don't draw the edge if the number chosen is 8 or 9. That would make the probability of the edge appearing to be 80%.

Through setting the parameters to your liking and repeatedly compiling the code you can generate many examples that you can use. If you're particularly ambitious you can add extra code spit out example that have (or fail to have) a perfect matching. Of course, Sage can help with that.

Odds and Ends: July 1, 2014

FlowChartA few minor changes:

  1. I've added the flowchart/tree diagram (PDF and tex file) to the Graphics page. When talking about linear systems I've found students slow to pick up the vocabulary of consistent/inconsistent and dependent/independent. The flow chart helps students to remember the difference.
  2. The important graph from the last post, has been posed as a problem: Find the derivative of f(x)=x^2\sin(1/x^2) if x \neq 0 and f(0)=0 at 0. I think it would be well suited as a warm up problem at the beginning of class to motivate the subsequent discussion.
  3. The NY Times has a good article on the difficulties with Common Core.