Archive

Archive for the ‘Uncategorized’ Category

It appears I am MathMan

June 20th, 2008

So, I had a pretty funny experience today.  When my Math C30 (pre-calculus) students walked in today, one of them held something behind her back and told me she was about to change the way I looked at the world.  I was speechless.  She then produced a comic book.  It’s called “The Add-ventures of MathMan”, and I’m the main character.  They were creating this in their spare for the last month or so.  Unbelievable.  They gave me a nice laminated hard copy, but also threw it up on the web here:

http://mathmanaddventures.wordpress.com/

My favorite bit:
Evil villain Theta: “But how did you escape?”
MathMan: “I shrunk one side of the triangle so the sum of the two smaller sides wasn’t greater than the third side.  The triangle ceased to exist!!”

Sometimes, being a teacher is a lot of fun.

P.S. Whenever you guys read this — thanks.  You made my day.

danschellenberg Uncategorized

Using Google Docs to Teach Statistics

June 3rd, 2008

In the spirit of sharing, here’s a lesson that I’m using with my Math B30 students right now.  We’re working on Data Analysis (Stats), and in particular, the normal distribution and related probabilities.  I was getting a bit tired of the dated examples in the text, so I thought I’d create my own problem with the students.

Each student will do a poll of other students in the school, with each student getting a minimum of 20 results.  The two questions they are asking are:

  • how many hours do you watch TV in an average week?
  • how many hours are you on the Internet in an average week (surfing, email, IMing, Facebook, YouTube, etc.)?

Each student will then post their results to a Google Docs spreadsheet I set up (one spreadsheet per class, like this one) that anyone can edit (to eliminate the need for them to log in).  After all of the students have added their results to the Google Docs spreadsheet, they can then use the aggregate data to perform the statistical calculations required (z-scores, what these results mean to a school population that we assume is normally distributed).

The handout that I’m giving the kids is available here.  I’ll let you know how it goes.

danschellenberg Uncategorized , , , ,

Trying to be more social…

January 15th, 2008

About a year and a half ago, I opted to quit blogging, and trimmed down my RSS subscriptions to be as few as I could.  The basic rationale was that I was trying to simplify my life as much as I could, and minimizing the time I spent online helped a lot.  However, I’m going to give it another go, though I’m going to keep a close watch on my time to keep myself sane (and married ;)  ).

So, after resisting for quite some time, I’ve finally joined Twitter. My username is danschellenberg, so let’s hook up and see how this twittering experiment goes…

Also, although I’ve been using Picasa as a web photo sharing site for awhile now, I’m going to be posting a few shots to flickr as well.  This is mostly so that I can be a part of the 366photos group,  as I’m making the mistake of letting others see my mediocre photos.  Ah well, you have to start somewhere…

danschellenberg Uncategorized

ECI blog feeds

January 15th, 2008

To simplify the subscribing process when getting yourself hooked up with everybody’s RSS feeds in this class, you can import this OPML file in Google Reader (or whatever other reader you use).  You’ll want to right click and save that file to someplace on your computer (that you can remember, like the desktop), then follow this screencast tutorial to import it into Google Reader.  Be patient, the tutorial seems to be taking a bit of time to load.

Enjoy!

danschellenberg Uncategorized

Hello world! Part 2

January 7th, 2008

This is the renewal of a blog that I began in the middle of 2004, then went on hiatus in 2006 due to my lack of patience for the amount of comment spam that I was dealing with.  We’ll see whether this attempt can achieve a bit more longevity…

Note that in the importing of all of my old posts, there are a few things broken.  In particular, categories have been discarded, and images that should appear in some posts do not.  Hopefully I’ll get around to fixing this soon…

danschellenberg Uncategorized

Running Ubuntu on a G3 iMac DV

June 16th, 2006

When attempting to install Ubuntu Dapper on an old G3 iMac DV, I kept running into stupid display problems (the boot process simply stopped at a blank black screen). After a bit of research, I finally discovered how to fix this problem, and will record it here for myself…

drop to console (ctrl - option F1)

** if you need to log in use the name ubuntu to log in. **
sudo nano /etc/X11/xorg.conf

change the frequencies in monitor section as follows:
** find this part in the file you are now in (xorg.conf) and make these changes **

Section “Monitor”
Identifier “Generic Monitor”
Option “DPMS”
HorizSync 60-60
VertRefresh 43-117
EndSection

** after the changes then type command-o, then command-x (save and exit nano)
** restart X by running the following:
sudo killall gdm
sudo /etc/init.d/gdm start

That should do it…

danschellenberg Uncategorized

Ubuntu Linux

April 1st, 2006

I’ve been a casual user of Ubuntu Linux for about a year and a half now, and really enjoy it’s simplicity and ease of use. When showing my computer science students a linux distribution, I inevitably choose the Ubuntu LiveCD. One small annoyance is that the menu’s do not auto-update when you install new software. This causes folks used to Windows a bit of angst. Just so I don’t forget it again, here is how to “rebuild” your menus after using Synaptic to install new software.

- open Synaptic, and install ‘menu’
- from the command line, run ‘update-menus’ to rebuild your menu

danschellenberg Uncategorized

Open Selected URL via Quicksilver

March 3rd, 2006

I am a big fan of Quicksilver, a free application launcher (and so much more) available for free on your Mac. It is a great way to avoid endless clicking when opening an app, and allows for some things that the built-in Mac OS X Spotlight search feature does not.

While marking my CS30 student’s php assignments, I was selecting the URL of the “live version” of their code, and thought their must be a better way than having to copy the URL, open Safari, select the location bar, and then paste in the URL. So, I spent a minute or two Googling it, and found a post from 43Folders explaining how to “Send to Quicksilver”.

In summary, you can open a selected URL from any application by simply hitting “CMD-Escape” (which sends the text to Quicksilver), and hit “Enter”. Two quick keyboard commands. Much nicer, and I will definitely be using the send to Quicksilver functionality much more…

danschellenberg Uncategorized

Fixing MS Office’s Stupidity Regarding Equation Editor

March 1st, 2006

Note to self:

To fix Word’s (completely inexplicable) occasional inability to open up the built-in Equation Editor on Mac OS 10.4 (perhaps earlier versions of OS X as well), just delete the whole ~/Library/Preferences/Microsoft folder. It took me a couple of minutes to find this again, and it’s the third time I’ve had to do it, so I’m making it easy to find if it happens again.

danschellenberg Uncategorized

Python Monte Carlo Simulator (Very Simplistic!)

December 11th, 2005

In teaching Math A30 here in Saskatchewan, there is a segment of the curriculum devoted to teaching students the basics of Data Analysis. Classic Monte Carlo simulations are touched upon, and students are given the opportunity to experience Monte Carlo simulations, whether through tossing dice, drawing cards, or any other “equally likely options” based event.

While some Monte Carlo simulation extensions can be made through the use of advanced calculators, I thought that a more interesting way for my students (and myself!) to experience simplistic Monte Carlo simulations would be to create a simple Python computer program that would automate the task for us. After a few hours, I came up with something that I think is quite useable. The result of one run of the program is seen below (formatting lost in HTML conversion, sorry!):

Trial # | Die Toss | # Tosses
1 | 1 2 6 6 3 5 6 6 2 4 | 10
2 | 6 3 1 5 3 1 5 1 4 1 5 6 1 6 2 | 15
3 | 3 6 3 5 6 1 3 4 1 4 5 3 5 5 3 2 | 16
4 | 6 1 3 1 1 2 4 5 | 8
5 | 6 1 2 2 2 5 2 4 6 2 1 2 4 5 2 2 1 2 6 5 4 4 1 5 3 | 25
6 | 1 5 1 1 2 4 4 2 4 2 5 5 5 1 2 4 6 5 1 5 5 1 4 6 6 4 3 | 27
7 | 3 6 1 2 2 4 1 1 5 | 9
8 | 4 5 3 1 4 2 6 | 7
9 | 3 1 3 2 5 5 6 6 6 4 | 10
10 | 1 4 4 1 6 2 5 6 2 3 | 10

Total tosses: 137
Number of trials: 10
Average tosses per trial: 13.7

This is a clone of the example given in Burt Thiessen’s Math A30 textbook, wherein he gives the example of 6 different hockey cards being placed in cereal boxes, and poses the question “How many boxes of cereal will you have to purchase until you have collected the entire set of six hockey cards?”.

Based on the output of the script from above, students would guess that on average, you would have to buy 14 boxes of cereal to be sure you would have all 6 hockey cards. However, taking it further, we could change the “trials” variable in the program to be 1000 instead of 10, and find that the average we came up with this time is 14.7. We therefore alter our original guess, now believing we would have to buy 15 boxes on average. We could continue increasing the number of trials until we are satisfied that we have come up with an acceptable conclusion.

A fairly straightforward exercise, but I think the students will appreciate this program, especially after having spent a few minutes attempting to do just a few trials on their own…

If you are interested in the Python source code, see below, or check out the plain text version.

Source code:

# Monte Carlo Simulation
# Dan Schellenberg      Dec 11, 2005

# set low and high values
low = 1
high = 6
trials = 10

################################################################################
# This section of code is used to format the output into nice columns
# Code from http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302380

import re

LEFT = ‘left’
RIGHT = ‘right’
CENTER = ‘center’

def align(text, width=70, alignment=LEFT):
    ”’ Align the “text” using the given alignment, padding to the given
    width. Strip off any existing whitespace on the side being aligned to
    and pad with spaces (’
‘) on the opposite side.

    Code from http://www.faqts.com/knowledge_base/view.phtml/aid/4476
    ”’
    if alignment == CENTER:
        text = text.strip()
        space = width - len(text)
        return ‘ ‘*(space/2) + text + ‘ ‘*(space/2 + space%2)
    elif alignment == RIGHT:
        text = text.rstrip()
        space = width - len(text)
        return ‘ ‘*space + text
    else:
        text = text.lstrip()
        space = width - len(text)
        return text + ‘ ‘*space

class FormatColumns:
    ”’Format some columns of text with constraints on the widths of the
    columns and the alignment of the text inside the columns.
    ”’

    def __init__(self, columns, contents, spacer=‘ | ‘, retain_newlines=True):
        ”’
        ”columns”   is a list of tuples (width in chars, alignment) where
                    alignment is one of LEFT, CENTER or RIGHT.
        ”contents”  is a list of chunks of text to format into each of the
                    columns.
        ”’

        assert len(columns) == len(contents),
            ‘columns and contents must be same length’
        self.columns = columns
        self.num_columns = len(columns)
        self.contents = contents
        self.spacer = spacer
        self.retain_newlines = retain_newlines
        self.positions = [0]*self.num_columns

    def format_line(self, wsre=re.compile(r’s+’)):
        ”’ Fill up a single row with data from the contents.
        ”’

        l = []
        data = False
        for i, (width, alignment) in enumerate(self.columns):
            content = self.contents[i]
            col =
            while self.positions[i] < len(content):
                word = content[self.positions[i]]
                # if we hit a newline, honor it
                if ‘n’ in word:
                    # chomp
                    self.positions[i] += 1
                    if self.retain_newlines:
                        break
                    word = word.strip()

                # make sure this word fits
                if col and len(word) + len(col) > width:
                    break

                # no whitespace at start-of-line
                if wsre.match(word) and not col:
                    # chomp
                    self.positions[i] += 1
                    continue

                col += word
                # chomp
                self.positions[i] += 1
            if col:
                data = True
            col = align(col, width, alignment)
            l.append(col)

        if data:
            return self.spacer.join(l).rstrip()
        # don’t return a blank line
        return

    def format(self, splitre=re.compile(r‘(n|rn|r|[ t]|S+)’)):
        # split the text into words, spaces/tabs and newlines
        for i, content in enumerate(self.contents):
            self.contents[i] = splitre.findall(content)

        # now process line by line
        l = []
        line = self.format_line()
        while line:
            l.append(line)
            line = self.format_line()
        return ‘n’.join(l)

    def __str__(self):
        return self.format()

def wrap(text, width=75, alignment=LEFT):
    return FormatColumns(((width, alignment),), [text])

################################################################################
# This is the actual Monte Carlo stuff…

from random import randint

def rollAll( low, high, trials ):
# Must “roll” each element in the list at least once…
    
    # print header
    print FormatColumns(((8, CENTER), (58, CENTER), (8, CENTER)), ["Trial #", "Die Toss", "# Tosses"])
    
    grand_total = 0
    grand_tosses = 0    
    
    i = 0
    while i < trials:
    #for each trial, each number must be rolled at least once
        arraySize = range(low, high+1)
        allChosen = []
    
        #populate list with all False elements
        for element in arraySize:
            allChosen.append(False)
        
        #initialize variables
        allDone = False
        tosses = 0
        total = 0
        numData = “”
        
        while allDone == False:
            num = randint(low, high)
            numData = numData + str(num) + ” “
            tosses = tosses + 1
            total = total + num
            
            # set the “this number rolled” flag to true
            allChosen[num - 1] = True
            
            # check if all “numbers” have been “rolled”
            for element in allChosen:
                if element == False:
                    allDone = False
                    break
                else:
                    allDone = True

        tossData = str(tosses)
        grand_total = grand_total + total
        grand_tosses = grand_tosses + tosses
        print FormatColumns(((8, CENTER), (58, LEFT), (8, CENTER)), [str(i+1), numData, tossData])
        i = i + 1
    
    #print results
    print
    print “Total tosses:”, grand_tosses
    print “Number of trials:”, trials
    print “Average tosses per trial:”, float(grand_tosses)/trials
    
    return 1

rollAll(low, high, trials)

danschellenberg Uncategorized