Friday, June 14, 2013

Told You So - MOOC forum participation is important

If you have been a regular reader of this blog and have a long memory, you may recall that back in December of 2012, in my article "Is the Udacity CS101 Course Watered Down?", I strongly emphasized my opinion that a vital part of getting the most out of the course is to participate actively in the forum. As strong as my opinion on this matter was, it was just my opinion. But now I've got data to back me up.

John Duhring has posted to the Google+ STEM Community today a link to an article "Effective Habits of Power Users: A Look At Recent MOOC Research". The article reports on a study of the small percentage of folks who completed the MIT "Circuits and Electronics" course that edX offered as a MOOC in March 2012. About 155,000 folks registered for the online course and only a few more than 7,000 completed the online course and earned a certificate of completion. There was a follow-up study to see what distinguished the folks who made it to the goal line from the rest. The report says the level of participation in the forum is the big differentiator.

Many years ago when I was a college student, I had the pleasure of sharing housing just off-campus with other students taking many of the same courses as I was taking. We had marvelous arguments with each other as to what the professor really was saying in the lectures we'd attended. They were friendly arguments with much hand waving at speeds approaching C to explain space-time dilation and other such hot topics. I'm quite certain that those discussions were an extremely important part of going to a residential college and greatly increased my learning.

I've been watching my wife's kids slow progress as commuter students to a local college and I think part of the problem is that they come home right after class and so don't have any of the discussions that cement into the brain the material of the course lectures. MOOC's bring a similar handicap of splendid isolation of the students from each other, but the forum provides a way for them to virtually get together and have those opinionated arguments with each other through the keyboard (hand-waving is not useful on the forums so some specific verbal skills are called for. At least you are safe from flying meter sticks approaching the speed of light).

So, again, if you take a MOOC, do take the time to participate in the forum associated with the course. Remember what Radio talk-show host Barry Farber used to say at the end of each broadcast: "Keep asking questions!"

Wednesday, June 12, 2013

A Chem teacher cautions against "Pseudoteaching"

Several times now I've come across mentions of "Pseudoteaching" in my reading, and I confess to not quite grokking what that meant. Today, the Google+ STEM community shared this short video and I think I'm beginning to understand.

"Blow something Up!"

I remember Mr. Greenberg, my high school chemistry teacher, but on the one hand I have trouble cataloging him as an "entertainer', but on the other hand I was always troubled by the seeming "magic" in chemistry class. See, when we stir these 2 clear liquids together, it turns pink. My brain would gripe "Why?". And that's probably why I went into software, not chemistry.

I think this video pairs nicely with the one linked to my blog post of 02/2013 "STEM Education Ideas".

Sunday, June 9, 2013

A Frequently Asked Question on the Udacity CS101 Forum

On the Udacity CS101 Forum, I've been surprised at the number of questions that were posted for quiz 2-18. For example there's this question: http://forums.udacity.com/questions/100057486/problem-with-is_friend-quiz?page=1&focusedAnswerId=100057509 and several many more that are much like it.

Now part of the confusion, I think is that when Python prints the string value "True" and prints the Boolean value True, there's no visible distinction between the 2 outputs. e.g.:

>>> print "True", True
True True
>>>

But I think it is perhaps worth noting that in the coursera course "Introduction to Systematic Program Design", there is strong emphasis in the course's "How to Design Functions" recipe on starting by writing down the function's "signature", the types of its inputs and of its outputs, which for quiz 2-18 would be:

# String -> Bool

(Mostly irrelevant is the detail that Udacity CS101 is working in Python 2.7 while the coursera course is working in "Dr. Ratchet", another programming language, and one that is new to me).

For as small a quiz as 2-18 is, and as often as similar questions have shown up in the forum, I think it is clear evidence that CS101 needs to add emphasis on function "signatures". It would also make sense to soup up the auto-grader for this problem to give more specific feedback if the function returns string values instead of the desired Boolean values.

For what it is worth, here's my answer to the question I cited in this article's opening paragraph.

I didn't actually run your code, but I see your function returns string values of "True" or "False". Python has special Boolean values of True and False (NB. no quotation marks). They behave in many ways like 1 and 0, but they are easier to read in the source code.

So, my best guess is that the autograder is looking for Boolean True and False, not the strings that you are handing to it. Further reading: Truthiness and Falsiness. By the way, the version of Python that CS101 is using has changed a little since I wrote that blog article last year. Also, be aware that None is another special value in Python.

Wednesday, May 29, 2013

Cheap, but not free. Modular code has a price...

Introduction and Spoiler Alert

Recently, Nico Ekkart asked on the Google+ Python Community for suggestions on how to speed up his Python implementation of Project Euler Project 14. I remembered my initial implementation of Project 14 had taken way more than the allowed minute of processing on my laptop and that I'd souped it up by adding a cache to get the run time down. I dusted off the files and compared the performance to Nico's. Sadly, his outperformed mine.

To see the requirements for Project 14, see: http://projecteuler.net/problem=14.

Spoiler alert: If you would rather solve Problem 14 on your own, don't follow the links below. In fact, you should read no further in this article, lest your thoughts be polluted with prior art. To see Nico's question and the associated discussion thread, see: https://plus.google.com/113176807122785773311/posts/MPA7LmLZdVW.

The source code for Nico's implementation is here: http://pastebin.com/bfDTte3p.

As I explained in Creeping up on OOP in Python - Part 1, all my Project Euler programs have a wrapper main program to time and report the timing of the run and to print the answer. The source code for that wrapper script is here: http://pastebin.com/trk7E1n9.

The source code for my initial uncached implementation is here: http://pastebin.com/wTzCfcXr.

The source code for my cached implementation is here: http://pastebin.com/AYYykyrj.

I ran each of these programs using Cygwin Python 2.7.3. The log of the runs is here: http://pastebin.com/ZUzeZjLW and includes one additional run. The difference was that I tweeked the cache size up from 100,000 to 1,000,000 entries to see if it would improve my run time. It did, but my run time still was behind that of Nico's code.

So what's the difference between my code and Nico's code? Well, a crucial non-difference is that both my cached version and Nico's code use a cache ("memoization") to save having to recalculate results that are already known. Far as I can see, a crucial difference is that I used a Python generator function to run through the specified sequence, and I used a simple class to do the caching. Nico's code is more in-line, mostly a simple while loop to compute the sequences, so there are many fewer calls going on. Nico's code uses one statement to do the caching where I used a simple object to implement the stashing of values in to the cache with a "method" (stash) and another method (value) to check whether a value is already in the cache On the one hand, I like Python's structuring provisions for generating sequences, but on the other hand, given the millions of times this program is invoking the next step in the sequence, the overhead does mound up to noticeable amounts of CPU time. I was also worried that perhaps I didn't have enough real memory to be able to cache all million values, so my cache had a bound on how much it'd cache. Nico's code just trusted in the virtual memory to allow a very large dictionary.

Summary of run times:

Nico's code     6.645 CPU sec
Drew's nocache 177.638 CPU sec
Drew's cache   28.501 CPU sec
Drew's big cache   16.863 CPU sec

Conclusion

The modular control structures in Python are remarkably efficient, but they are not entirely free of overhead. I stopped tuning after I got the run time below the requirement of "no more than a minute", but clearly I was off the pace by a factor of 4 or so. Was the structure of my functions and objects worth that cost? Well, for having met the requirements, I think so. I have to concede that Nico's code was so short that I do find it hard to argue that my function def's and Cache class added any significant amount of clarity to the code. As for Nico's question of how to make his code run faster, the stackoverflow pointers in the original comment thread may help get his run time down even further. Memoization is the big performance win, and thanks to Python dictionary data type, that is darn easy to implement.

Friday, May 17, 2013

Education Automation - R. Buckminster Fuller

A few months ago, in response to one of my "education" tagged blog posts, an old friend from high school contacted me via Facebook and suggested that I really should take a look at the book "Education Automation" by R. Buckminster Fuller, the famous architect. The book was published way back in 1961 and for someone without access to Doc Brown's DeLorean, it had remarkable foresight. He basically predicted the Internet, though he called it 2-way television.

The Book

The book is a slim paperback volume, only 88 pages long. It was put together at a time when Southern Illinois University was undergoing major expansion in 1961 - a transition from being a state teacher's college to being a full-fledged university. Fuller had been invited to give a talk to the committee planning the new campus. The book doesn't quite read like it is a transcript of his talk. I believe it is more like a report by Fuller of what he said.

I have to give credit to the Westbury Public Library for finding a copy of this book for me to read. They borrowed it from the library of Hartwick College way off in Oneonta, NY, about a 200 mile drive upstate from Westbury. I was tickled to notice the 1961 price of the book printed on the book's cover: $1.95. If you convert that into how many gallons of gasoline you could get for $1.95 in 1961, and then figure out what the contemporary price for that many gallons of gasoline would be, I suspect the $1.95 maps to a pretty good approximation of what a slim academic book would cost these days. The years have not been kind to the purchasing power of a dollar.

There are plenty of smells of age to be found in the book such as frequent mention of "men" where a more contemporary book would surely have said "people". And, I was surprised at how high an opinion Fuller seems to have of himself. I expect a tad more humility from great men of the past.

What did he call for?

Fuller foresaw a future in which "earning a living" was no longer required. He expected that change was going to arrive within 10 years of the time he was speaking in 1961. He expected that the only lasting world industry would be education. He anticipated that scholars would stay for years and years at the universities, "for the rest of their lives", "developing more and more knowledge about the whole experience of man".

One somewhat off-the-wall suggestion from Fuller is that a 200 foot diameter (or larger) geodesic dome be suspended 100 feet above the campus and be covered with light bulbs on the entire interior and exterior surface, each bulb under the control of a computer, so the 'Geoscope' would be a gigantic display screen. "It will make possible communication of phenomena that are not at present communicable to man's conceptual understanding." I've seen enough movies to have my doubts about any good coming from a large screen for mass viewing. Brings to mind Apple's 1984 commercial.

He clearly suggested that the university acquire as much land as it can. But forget about any permanent structure anchored to whatever the shape is of today's curriculum. Everything should be dynamic. e.g. bring in a geodesic dome via heavy-lift helicopter to serve as an auditorium whenever you need another big auditorium. Or just build a gigantic half-mile wide geodesic dome to enclose the entire campus and give people large clear spaces to do their work. "Don't waste dollars on great, heavy stone masonry and any kind of Georgian architecture."

What did he get wrong?

From my 21st century perspective, he did get some things wrong. He still seems to expect that education is something that is done by herding large groups of students into giant auditoriums. Current consensus seems to be that the Internet particularly obsoletes the large-to-the-point-of-student-anonymity lectures, replacing them with on-demand viewing of pre-recorded lectures. (e.g. MOOC's).

I wish I knew more about what they actually did there at SIU after the planning sessions. I Google searched for images of the Southern Illinois University campus and only found a few pictures, none of which seem anything like Fuller's suggestions. I'm slightly more familiar with a more recently developed college campus, Liberty University. Though I have never set foot on Liberty University's campus, we received a magazine from them a few months ago detailing their campus expansion projects. From what I can see, Liberty University initially built large warehousey "temporary" buildings, but then in more recent years has been replacing those buildings with new prettier more permanent structures.

Fuller's 1961 advice was to build with the inspiration of circus tents, not wasting money on, e.g., Georgian architectural detailing. From what I can see of the continuing development of Liberty University, they initially erected structures that were slightly more solid then circus tents, but without significant ornamentation, but more recent structures are in a style that would be fitting for colonial Williamsburg, with lots of brick and big decorative columns and with large windows consisting of many small panes. It would seem that Fuller was overlooking the role of campus buildings in inspiring pride in alumni as a stimulus to continuing generous donations. In the book, he made little mention of budget constraints. He also, despite his own involvement in campus athletics (he'd been a football quarterback in his high school years), seemed to pay no attention to the huge investments large schools seem to make in sports facilities.

I noticed that Fuller's advice seemed to pay no attention to matters of infrastructure: e.g. bathrooms and parking and/or provisions for on-campus transportation. Research labs need plumbing, fume hoods, marker boards, bookshelves (at least they still need those today), desks, chairs, network access, electricity, heating, lighting and air conditioning. Much more than just the generous amounts of space Fuller advised should be acquired and enclosed.

He had a curious fixation on a proposal for a large domed display screen that could be used to display images, charts and graphs to help the people on campus to attain a commonality in their point of view. I wonder if Leo Villareal would give any credit to Fuller for Villareal's "Cosmos" installation on the Cornell U. Johnson Art Museum. Villareal's piece makes sense of what had been a seemingly pointless architectural detail of the museum building, which building has been compared to the shape of a gigantic sewing machine.

The foreword of the book says Fuller served as a research professor at SIU. I hope he didn't get overpaid for the advice he gave but that they apparently didn't follow. If you have affiliation with SIU and can say more about what influence Fuller's suggestions had on the development of that campus, I'd sure like to hear from you in the comments.

Maybe Fuller was just way ahead of his time, but I'd have an easier time expecting a virtual campus that is spread around the world and reconfigured as different specialists get involved in a research project. A campus where there's no "there" there? Good luck figuring out where home-game sports events are going to be held. Perhaps the central feature of the physical campus will be a large Internet connected data center/online digital library to facilitate research and online collaboration by the people affiliated with the university, wherever they may be.

Oh, and I bet there'll be a lovely administration building with columns and brick and many window panes and a board room for the meetings of the trustees (who probably are going to lag on acceptance of online meetings). I'm not advocating that all future research be conducted in the researcher's home kitchen. Space (rented?) with suitable labs facilities would be acquired wherever the researcher chose to be. I foresee big demand for lab space in Hawaii. Lovely weather - especially compared to Ithaca, NY, just to name a place where you can find a conventional physical campus today.

Thursday, May 16, 2013

How does Python identify the type?

In the CS101 forum, a student noticed that types significantly influence the computations in python, but that we generally don't declare types in Python. They wondered how this can be so.

In the speed of the light question,when the prof changed the value of 1 to a float value 1.0,the answer was much more accurate,i want to know , how and why in python unlike other languages,there is no need to define the type?

To see the original discussion thread, see:http://forums.udacity.com/questions/2001224/how-does-python-identify-the-type.

My reply to that question:

In Python, variable names have values and values have types. So if I say x=2, the type of the value of x is int. I can then say x="dog" and now the type of the value of x is string. Python knows the type of a literal in the source from the syntax (e.g. quotes to make something be a string value, or square brackets to make something be a list or curly brackets to make something be a dictionary. Number without a decimal point for an integer. Number with a decimal point for a float. At runtime, all the values of variables in memory have a specific type. Operations on those values therefore have methods that know how to work with those types (or an exception is thrown), and produce results of a specific type.

Python might not know what that type is until runtime, but hopefully the programmer knows what they meant to produce and gets it right. Other languages ("bondage and discipline languages") are much more demanding that all be declared at compile time, but then you might end up with a procedure that you'd like to use on an object in your program, but get snagged that although the object behaves like you need it to, it isn't the exact type that the procedure was coded to expect. Python says "if it walks like a duck and it quacks like a duck, then it's a duck" (Hence, "duck typing"). So if the object provides whatever operations are needed for the procedure, you're good to go.

Broad categories of types include orderable types for which lt and eq (comparison) operations are defined. Another broad category is "iterables". You can easily write a procedure in Python that'll happily operate on any type that meets the requirements of the procedure. e.g. if you can compare objects of the given type and decide how to put them into order (i.e. which is "greater" and which is lesser), then you can probably feed objects of that type to your sort procedure - even types that you created long after you wrote the sort procedure. If you write a procedure that takes an iterable, it can be written to be happy with a list or a file or a generator (a special kind of procedure that returns a value but that you can then resume to get the next value) - and the procedure can be happy as you apply it in amazing new ways.

That's one of the definite sources of the power of Python. This type freedom has its downsides too, such as there being surprisingly little that can be statically verified about a piece of Python code. At "compile time", Python doesn't really know what is going to happen at run time. If I was implementing a nuclear reactor control system, I think I'd feel safer writing it in Ada, not Python. But, most days I definitely am not writing nuclear reactor control software or anything that could seriously kill someone if it has a flaw. That sort of software puts a seriously literal meaning into the phrase "fatal flaw". For a reminder of how fatal a software flaw can be, see: An Investigation of the Therac-25 accidents.

Here's a highly technical talk related to this topic of types which I hardily recommend. Have a pad and pencil handy as you watch it and jot down things he mentions that you don't know about, then Google for more info on those words later. Dynamic Languages Strike Back. After you are more comfortable with those words, you might even want to watch the video again.

Tuesday, May 14, 2013

Education's Future: "Go Do Something Interesting".

Another interesting TED talk on the future of education. The speaker is Seth Godin. The question is "What is school for?".

http://www.youtube.com/watch?v=sXpbONjV1Jc (17 minutes)

As usual, it is easy to see how that could work out for a self-motivated student, but what about the unmotivated students? Will they just waste time until school is over? Spending hour after hour playing World of Warcraft doesn't sound like a well rounded education to me.

Life could be awfully complex for a teacher in the future if all the students are going off in their own directions and each student is looking to the teacher during the day to answer questions they have from the diverse lectures they listened to last night. I suppose there can be various specialists on staff, and depending on the questions, the teacher could redirect the student to the appropriate specialist. Except for the lower grade levels, that isn't all that much different from the staff of schools today, except for the change from having assigned time slots to sit with each specialist on your schedule.

Unclear to me is how the school will insist on a "well rounded" education. I suppose this comes down to some assumptions on what school is for. I believe that one of the things school is for is to educate the students to the point where they are prepared to learn new things in the future. That calls for some fundamental reading and writing skills, some basic math skills and some elementary knowledge of history and literature. This may not fit the student's opinion of what is "something interesting", but if the school hands out diplomas to students who aren't prepared even to be knowledgeable voters, then the diploma doesn't mean much. This is where the cynic would point out how little a high school diploma means today.

On the one hand, I can see a case for loosening up a school's schedule, spending less time in required classes, but on the other hand, I can see an awful lot of students frittering away the time released for them to go do something interesting. Do you see a way to structure things such that no one gets left behind and folks who are motivated can go as far as they want to go?