# Programming, Probability, and the Modern Mathematics Classroom

Consider the fact that you are reading this blog on some device, be it a computer, tablet, mobile phone, phablet, etc. Every aspect of what is being displayed is a result of some form of programming. Programming is everywhere, be it the CSS to handle the layout, or the HTML to render the text, or the protocols to transmit the information electronically from some server to your viewing device, or or or or … As such, the sooner students get exposure to the various aspects of programming, the better equipped they will be for the fast changing world that lies ahead.

There are a lot of ways to introduce programming into the classroom and this has been an ongoing effort.

Nowadays there are so many programming languages that it seems like a daunting task to even start. To rattle off some current active programming languages in no specific order and with no intention of being exhaustive we have C/C++, Java, Python, Ruby, Lisp, Visual Basic, Haskell, etc.

So where to start? The answer is, anywhere! There’s programming for developing graphical user interfaces (GUIs), video game programming, database programming, programming for mobile applications, numerical programming, etc. If you don’t start, then you won’t start! So just start!

As such, this series will be focused on ways to introduce quantitative / numerical programming into the math classroom by considering problems that can be solved via probabilistic methods (Monte Carlo Methods). One of the things that this series will aim (hope) to do is get away from the “boring” problems of writing a computer program to, say, find the area of a circle if the radius were provided, but rather to engage students in solving problems that are probabilistic in nature. The added positive side effect is that it will expose students early on to Probability and Statistics even if in an informal sense and it will demonstrate that mathematics isn’t just about tidy little formulas that always resolve nicely into an answer.

Real problems in industry cannot all be solved in a complete theoretical manner. The constraints of the industrial mathematician, researcher, engineer are often rooted in budgets, schedules, profitability, etc. Take, for example, meteorology — a very, very sophisticated field of study. One of the areas of study in meteorology is weather forecasting. If, I know that at 12pm it is raining heavily in New York City, I can say with almost absolute certainty that at 12:01pm it will still be raining heavily in New York City. But what can be said about the weather one hour later? One day later? One week later? It may not be raining heavily for one continuous week, but what will the weather be like? Sunny? Warm? Windy? When Superstorm Sandy devastated the New Jersey coastline, weather forecasting models provided several plausible scenarios for the trajectory of the storm. Figuring out where a storm like Superstorm Sandy will hit exactly is a daunting, if not impossible task. However, the uncertainty in a forecast can be controlled by using sophisticated simulation and weather modelling techniques. And this requires quantitative programming.

Monte Carlo Methods are not the only, nor are they the final, word in quantitative programming. To name-drop a little bit so that the uninitiated reader can have searchable terms, here is a non-exhaustive, unordered list of topics:

• Quasi-Monte Carlo and randomized quasi-Monte Carlo Methods (I have some published work here.)
• Genetic algorithms (I have some work here too)
• Genetic programming (technically different from genetic algorithms)
• Bootstrapping
• Finite difference schemes for solving partial differential equations
• Finite element methods
• Symbolic computation

## Some first steps

Here is what, you, the instructor will need to ensure exists. This is geared for high school students in their junior and senior year.

• You will have to have a decent understanding of a programming language of your choice. If you are not programming savvy and would like to learn, please contact me and let’s see if something can be arranged with me either directly with your school or private instruction. If you want to learn on your own, I recommend learning Python. Here are some links that seem reasonable for self-learning: learnpython.org, codeacademy.com, and Python’s tutorial. Additionally, if you stick with Python, then hopefully the examples in this series will be intuitive enough so that you can just move forward on your own.
• You should have a classroom or get access to a classroom equipped with computers.
• Your students will need to have installed, preferably, the same version of the programming language that you are working with.
• You and your students should have patience, fun, and a willingness to learn and try something new.

The next thing to do is to get students familiar with the programming environment. I will use Python in this series. I’m on Python 3.1.x and I’ll use the default IDE (IDLE) that comes with a standard install of Python. One way to get students started with programming is to provide a full programming course. However, I would recommend that the students just be given the code and their tasks should be to

• comment it line by line and
• modify it as per the exercises.

When students can comment the code they will immediately know what they know and what they don’t know. Additionally, for those who have some anxiety about programming, they don’t have to learn “by fire”; they can take a “look-and-see” approach to gain familiarity. The instructor can step in and fill in the gaps for the student and perhaps the class. Of course, there are going to be those students who will catch on quite quickly. For them, let them advance.

## Some tips for the instructor

In any classroom setting, there will never be a uniform rate of learning; some students will advance faster than others. So, don’t worry about controlling pace. Students will learn at the pace they will learn — it’s not synchronized swimming. Just set goals, keep tabs, and motivate. That is all that an instructor really should have to do in terms of teaching.

## What to look for in posts of this topic

This post was about the “why”. The remainder of this week’s posts will focus on the actual “how-to” for instructors / education institutions interested in integrating programming into their math classrooms. Posts in this series will be tagged as “ppmmc”.

## Need help? Interested in introducing something like this at your educational institution?

Get in touch! We’ll be happy to discuss, advise, assist, implement, demonstrate, etc.

Do you enjoy this blog?
Consider supporting with a contribution!

## 20 thoughts on “Programming, Probability, and the Modern Mathematics Classroom”

1. David Wees

I’ve taught early programming concepts to children as young as four years old, and Python is not the best choice for children that young (Turtle Art, Blockly, or Scratch are good), but I think it is an excellent choice for children who are text-literate already, or building on solid skills with text (learning how to program almost certainly helps build literacy skills).

Thank you for working on this project, Manan. I’ve been working on the same project at my school (with some success – I have introduced programming concepts to kindies, 2nd, 3rd, 4th, 5th, 6th, 8th, 9th, and 10th grade students at some point during the past three years, and it has absolutely been rewarding.

1. Manan Shah Post author

Hi David,

Yes, I completely agree. Python is probably not a good choice for the young kids. I remember doing Turtle Art when I was kid and it was quite enjoyable! I also remember taking Pascal in the 9th grade and it was incomprehensible. I finally learned C++ after I finished undergrad because I was working and had to learn it out on my own. Go figure!

2. Manan Shah Post author

Agreed! Java is also a great language to introduce as it too is very popular.

3. James Slocum

I fully agree with teaching Python as a first language! There are many aspects that make it ideal. The syntax is robust and straight forward, It forces good indenting practices, and it is used by real industry (unlike Alice or Scratch). While Alice and Scratch do have an audience with younger kids, I don’t think it wise to underestimate what a child, even a young child, can learn with practice and interest. I also think Java is a good first language for teens since Minecraft mods can be written in Java and this will generate interest.