Tag Archives: computer science

Analyze, hack, create

One of these days I’ll get back to blogging about the mathematics courses I teach, which make up the vast majority of my work, but the MATLAB course continues to be the place where I am working the hardest, struggling the most, learning the biggest lessons about teaching, and finally having the greatest sense of reward. This week was particularly rewarding because I think I finally figured out a winning formula for teaching a large portion of this stuff.

This was the last in a three-week series on introduction to programming. We had worked with FOR loops already. I had planned to look at WHILE loops in the same week as FOR loops, then have the students play around with branching structures in week 2, then have them apply it to writing programs to do numerical integration week 3 for use in their Calculus II class in which most of the class is currently enrolled. But the FOR loop stuff went very roughly. So I moved the numerical integration stuff up a week and saved the entire remainder of looping and branching structures — WHILE loops, the IF-ELSEIF-ELSE structure, and SWITCH — for week 3.

I approached it like this.

The majority of their homework consisted of watching three videos: one on general programming in MATLAB, another on MATLAB loop structures in general, and a third on IF and SWITCH statements. That’s about 20 minutes of straight viewing; I told the students to budget an hour for these, since they’ll want to pause and rewind and work alongside the videos. Then, the majority of their homework was this M-file:

%% Script M-file for April 5 Prep/HW for CMP 150.
% For each block of code below, write a clear, English paragraph that
% explains what the code does. You can play with each block of code by
% removing the comment symbols and running this file. (You can "uncomment"
% lines by deleting the percent symbol or by highlighting the code you want
% and selecting Text > Uncomment from the menu above.)

%% Code example 1

 x = input('Please enter in a number less than 100: ');
 while x < 100
     x = 2*x - 1;

%% Code example 2

 x = input('Please enter in a number: ');
 if x>=0
     y = sqrt(x)
     y = exp(x) - 1

%% Code example 3

 value = input('Please enter in a whole number between 1 and 20: ');
 switch value
     case {2, 3, 5, 7, 11, 13, 17, 19}
        disp('Your input is a prime number.')
     case {1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20}
         disp('Your input is a composite number.')
         disp('I do not think you entered in a whole number between 1 and 20.')

In other words: Here’s a bunch of code. Write up a plain-English description of what everything is doing. That was their homework. (Here’s the full assignment.)

Then in class, we played a game. For each code sample, I asked, “What if I entered [fill in the blank] to this bit of code?” For example, for code sample #1, what would happen if I entered in 100? One student immediately said, “Nothing”. Another said “It would give you a ‘0’ because that’s what ‘100 < 100’ returns as in MATLAB.” Then I had them close their eyes. “How many say, ‘Nothing’?” Count the hands that go up. “How many say ‘0’?” Count those hands. Put the tally on the board. The result: 7 for “nothing”, 6 for “zero”. Instant discussion fodder.

(By the way, this would have been a perfect place for clickers. I’m working on that.)

Next I asked, “What would happen in code sample 1 if I put in a negative number?” One guy said: “I know! I did that, and the thing kept running and never stopped, and I had to unplug my computer!” So I showed them all Control-C; then asked, “Why did that [the failure of the program to stop] happen?” In no time at all — a high-order discussion about an important related topic to looping structures (avoiding infinite loops) that I had not even planned to bring up.

We played that game for 20 more minutes. Students were into it. They were coming up with their own cases. We tried entering in ‘Hi mom’ to code sample #1 and it actually gave something back. It was mysterious and entertaining and nerdy. They discovered that testing out extreme cases is not only important for understanding your code, it’s fun. And it was a lot better than lecturing.

The best thing is, when I got them finally into their lab problems, they were asking better questions. “I think I can do this program with a SWITCH statement, but could I make it better with an IF statement?” And: “I’ve got all the cases listed out here in my SWITCH statement, but I wonder if I could just use a vector or LINSPACE to list them out instead.

So that’s going to be my approach from here on:

  1. Analyze: Look at someone else’s code and write out a complete, plain-English description of what every part of it is doing.
  2. Hack: Take the same code and modify it, tweak it, rewrite it, throw extreme cases at it. This is the bridge between reading code and writing code.
  3. Create: Write some code to do something new — now that you’ve learned the language from someone else’s use of it.

For all I know I could be totally reinventing 40-50 years of established best practices in computer science pedagogy. But it’s pretty exciting nonetheless.


Filed under Education, MATLAB, Problem Solving, Teaching, Technology

And so it begins: Lab #1 in the MATLAB course

The MATLAB course began in earnest on Monday this week with our first full-length lab activity session. This was the second overall meeting, the first one being some organizational stuff and a lengthy fly-through of the main features of MATLAB. What follows is a breakdown of what we did and how it went, which also serves as an invitation for critique and suggestions in the comments.

First, some context. I intend for this course to be heavily hands-on with an emphasis on self-teaching within reasonable bounds. I laid a ground rule in the first class meeting that any question of the form “How do you do ____ in MATLAB?” was going to be met with the responses “What have you found in the MATLAB help documentation? What have you found via a Google search? What have you found out from your lab partner?” I’m not above giving hints to students in the class, but I insist that they exhaust all efforts of their own first before I come swooping in to the rescue, thereby creating a dependency upon me that makes their future, independent use of MATLAB problematic. So students have to do a considerable amount of individual work to learn basic commands and concepts before they come in to lab. Maybe I’ll blog more about that idea later, but now I want to get on to the activity itself.

First of all, students did this homework assignment in the week before the lab. The main item is to produce a graph of y = \sin(1/x) from x = -1 to x = 12. The theme of the lab this week was plotting, as you’ll see. This homework item forces them to figure out the basic usage of the PLOT command in MATLAB. It also forces them to figure out that you can’t just type 1/x in MATLAB if x is a vector.

The first 10 minutes of class are spent taking a quiz over the basic elements of the homework. Then, the lab activity itself. Here it is: CMP150-Lab1 (PDF, 201Kb). The summary:

  1. Reproduce a graph of a somewhat complicated function (related to the one from the homework set) with a bunch of extras added in the graph. Create a JPG and submit it.
  2. Create a data set by hand and plot it, and add some extras, including a text annotation. But this time, no pointy-clicky stuff using the Plot Tools window — you have to do it all by hand from the command line and put the commands into an M-file and submit that. (The moral: You need to know how to create a plot both ways, using the pointy-clicky stuff and without using it.)
  3. Create a two-item data set by hand and plot it, and make it look pretty. Create a PNG and submit it.
  4. Create single plot with 6 subplots arranged in a 2×3 grid. Create a PDF and submit it.

The philosophy here is that plotting stuff is fun, and there is a kind of immediate gratification when you create something visual that will hopefully serve as a source of low-hanging fruit for beginning MATLAB users. So students learning MATLAB should be introduced to the ins and outs of basic function and data visualization before they see much of anything else. And plotting also provides a convenient inroads to talking about M-files and other important MATLAB components.

So, how did it all go? I have to admit it didn’t start well. The homework set was due at 10:30 AM on Monday, and a good portion of the submissions had a timestamp in the neighborhood of 1:30AM Monday. There were several instances of students not reviewing their notes or watching the assigned tutorial videos before starting on the homework, which they did after midnight on the day it was due. So several teams took around 30-40 minutes just to get a basic plot of A = e^{-0.2t} \sin(2t) up on the screen — simply because they didn’t know how to create a vector, use the exp( ) command, or use the plot command, all of which we covered last week and in the homework.

I don’t say this to shame my students. Rather, I think it illustrates some important psychological points that play into teaching MATLAB, or any kind of technical computing topic, at this level:

  • Students who are at the entry level of using technical computing software believe that the software will adapt itself to what they are thinking, rather than the harsh reality of the other way around. When students want to plot e^x, they should just type it the way they write it. That may be the ideal case, but MATLAB just doesn’t work that way, and that’s a big problem for some people.
  • Most people who do any amount of computing will vouch for the importance of being able to surf the help files of a program to figure out what you need to do if you have something to get done. But freshmen in college have mostly never heard of such a thing. They are still making that transition from high school, where (typically) the teacher tells you what you need to know. Asking students to look up a command in a help system and then play around with it before coming into a lab session where they’ll be asked to do more of the same, is asking students to make a HUGE developmental leap. Or at least to begin to make it.
  • I’ve said it before, but the notion that today’s students are digitally native is both unfounded and dangerous. My students are not unintelligent, but many of them had no idea what a PNG was or how it was different from a JPG or PDF (this week’s homework asks them to do some research on that topic); many have never seen anything like a command line; a few of them didn’t even know how to attach something to an email to submit it. The so-called and self-appointed ed tech illuminati pushing this digital native idea have simply got to come back to reality so we can teach these ideas and skills rather than assume them.

Anyway, despite the rocky start, we ended well. I softened my stance, just this once, on giving out hints and how-to advice for a couple of things, and the infusion of progress begat more progress, this time by the students themselves. Most people didn’t make it past the second problem but everybody turned in reasonably good work by the deadline this morning. And by the end, teams were getting excited that they had figured some MATLAB out.

I think we can now move forward into next week, which is about working with data files and doing basic statistics, with confidence and with a little more understanding of what this class is all about. Here’s the homework!


Filed under Education, Educational technology, MATLAB, Teaching, Technology

Links for Tuesday

  • What’s that smell? It could be the latest in biometrics.
  • At Slashdot, a discussion on combining computer science and philosophy. I think that, in general, there is a lot of really interesting yet uncharted territory in the liberal arts arising from combining computing with [fill in humanities subject here].
  • Circuit City hits Chapter 11. The only reason I’m sorry to hear about this is because I know people who work for Circuit City who might lose their jobs. But that’s the only reason. There used to be a time, when I was a teenager, when going to Circuit City to paw over all the tech stuff was fun and exciting. Now when I go, it’s a game of “dodge the irritating service rep”.
  • Some nice tips on getting the most out of Google Scholar. Especially useful if, like me, you’re in a place that doesn’t have access to a lot of technical journals.
  • Mike at Walking Randomly is finding symbolic integrals that the new version of MATLAB can’t do. This is a really important series he’s doing, and his articles are a great resource for MATLAB users.
  • Speaking of math, here’s Carnival of Mathematics #43.
  • The University of Cincinnati is trying out a market-based approach to its various schools that might levy budget cuts on programs that don’t produce. What a concept! Of course the anti-free market people are running wild in the comments.
  • Finally, make sure you thank an engineer today.

1 Comment

Filed under Crypto, Engineering, Higher ed, Math, Technology

Crypto two-fer

  • Have you seen the NSA Kids website yet? It’s pretty nifty. High school math and science teachers, you should get your students on there. I am eagerly awaiting somebody to make it into an animated show on Disney or early-morning Discovery Channel for my two girls. (Anything, for the love of God, to displace my 4-year-old’s obsession with Hi-5.) 
  • Also pretty nifty is the Spelman College Science Olympiad, which has teams from historically black colleges and universities competing in teams to solve problems in programming Google Gadgets (Google is a sponsor of the event), cryptography, website design, hardware/software integration, and robotics. All in the space of one weekend! Sounds like a lot of fun, and it seems like a really good way to promote computer science education on the college level. [h/t here to the Official Google Blog]

Comments Off on Crypto two-fer

Filed under Higher ed, Math, Technology

Computer science on the rebound?

Back in September 2006, I wrote about a new and innovative approach that Georgia Tech was taking towards its computer science curriculum. It appears that this approach, plus an improved job market for computing professionals, is helping turn around a fairly gloomy period for the field:

The Georgia Institute of Technology has revised its computer science curriculum to move away from a traditional hardware-software approach to much more emphasis on the creative process and the roles computer science majors go on to assume in their careers.

Giselle Martin, who directs student recruitment for the College of Computing at Georgia Tech, said that undergraduate applications are up 15 percent this year — in part due to new approaches to explaining the field. One key audience is parents, Martin said. Many remember the horror stories of the job market a few years back and Georgia Tech believes that it can break through that out-of-date mindset most directly with actual employers. So in April, when the college holds a series of events for accepted applicants, there is a panel for parents featuring employers who recruit at Georgia Tech talking about the jobs available and how much demand there is for new graduates.

And there’s this from Virginia Tech:

A new course focuses on problem solving, and several courses are being shifted to focus more on “how to think like a computer scientist,” he said. “We are thinking about how we portray ourselves and what we do,” [Cal] Ribbens [associate department head in computer science] said. “We do not want to be seen as just offering a bunch of programming classes.”

Indeed. There’s a lot of talk going around our campus and at the ICTCM about offering intro courses that focus on problem-solving and the methodology of the discipline, rather than just one little (but deep) slice of content. That certainly seems to make the front door of a major easier to get into. Right now, at least in math, it seems like many students who might do well in a math-related major are either turned off to the subject, or even shut out of it, because their first introduction to math is a technical calculus course, which is almost nothing like what the discipline of mathematics is actually about.

[h/t Inside Higher Ed]


Filed under Education, Higher ed