May 22, 2013

World's silliest arduino-based electronic musical instrument

This is the world's silliest arduino-based electronic musical instrument. It is a mashup of the "Melody" tutorial and the "Button" tutorial.  The code I modified (see below) strips out the part where the tune is actually played and instead plays a single note when each button is pressed.



/* Melody
 * (cleft) 2005 D. Cuartielles for K3
 *
 * This example uses a piezo speaker to play melodies.  It sends
 * a square wave of the appropriate frequency to the piezo, generating
 * the corresponding tone.
 *
 * The calculation of the tones is made following the mathematical
 * operation:
 *
 *       timeHigh = period / 2 = 1 / (2 * toneFrequency)
 *
 * where the different tones are described as in the table:
 *
 * note  frequency  period  timeHigh
 * c          261 Hz          3830  1915  
 * d          294 Hz          3400  1700  
 * e          329 Hz          3038  1519  
 * f          349 Hz          2864  1432  
 * g          392 Hz          2550  1275  
 * a          440 Hz          2272  1136  
 * b          493 Hz          2028 1014 
 * C         523 Hz         1912  956
 *
 * http://www.arduino.cc/en/Tutorial/Melody
 */
  
int speakerPin = 9;
int button1 = 3;
int button2 = 4;
int button3 = 5;

int val1 = 0;
int val2 = 0;
int val3 = 0;

int length = 15; // the number of notes
char notes[] = "ccggaagffeeddc "; // a space represents a rest
int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 };
int tempo = 300;

void playTone(int tone, int duration) {
  for (long i = 0; i < duration * 1000L; i += tone * 2) {
    digitalWrite(speakerPin, HIGH);
    delayMicroseconds(tone);
    digitalWrite(speakerPin, LOW);
    delayMicroseconds(tone);
  }
}

void playNote(char note, int duration) {
  char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
  int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };
  
  // play the tone corresponding to the note name
  for (int i = 0; i < 8; i++) {
    if (names[i] == note) {
      playTone(tones[i], duration);
    }
  }
}

void setup() {
  pinMode(speakerPin, OUTPUT);
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  pinMode(button3, INPUT);
}

void loop() {
  val1 = digitalRead(button1);
  val2 = digitalRead(button2);
  val3 = digitalRead(button3);
    if (val1 == LOW) {
      playNote('c', 1 * tempo);
//    } else {
//      playNote(notes[i], beats[i] * tempo);
    }
if (val2 == LOW) {
      playNote('e', 1 * tempo);
}
    if (val3 == LOW) {
      playNote('g', 1 * tempo);  
}

}

Hoop jumping

INCIDENTAL COMICS: Message to a Graduate
Image credit: Grant Snider, Incidental Comics

By the end of high school, all I could see was the hoop jumping. I was so sick of it: every class was predetermined for me with only my extracurriculars to numb the boredom of the required classes. I looked forward to college knowing that while I would have to take general education classes, at least I would have options to choose from.

By the end of college, I saw that while the hoops were fewer and further between, I still detested them. I put off some general education classes until the last year I was in school.  I looked forward to going to grad school where there would be no hoops to jump through.

By the end of grad school, I realized that I was wrong about the hoops.  They were still there, they were just disguised. I grudgingly jumped through them and looked forward to getting out of grad school so I could be free of the hoops.

By now I've come to understand that the hoops never truly go away.  But what this comic says to me is that I can choose my own goals which are interesting to me.  That makes all the difference in the world.

(Thanks to @rjallain for pointing the comic out to me on twitter.)

May 08, 2013

New rules for screencast assignments

I tend to really hate rules in the classes I teach. I like the formats to be free flowing so that students are empowered to learn in their own way and in their own style.

I like screencasts as assessments, especially when I'm able to get them watched and responded to rapidly as intended. But anyone who makes blanket statements about students today being "digital natives" who grew up online creating and sharing content have not been in the same classrooms I've been in.

For next year I have some new rules for submitting screencasts:

1.) I will only accept URLs as screencast submissions.  I don't want a file as an attachment to an email in whatever crazy format came out of the camera. I don't want an audio file with a snapshot of the work done. I don't want a thumbdrive with each screencast file sized over 300 MB. I want a link to your screencast which is on youtube, screencast.com, vimeo or similar.

2.) All students will be shown this Public Service Announcement on the first day. If I can't see the work done on the page while I'm in full screen mode, then what is the point of getting the visuals? Not that it is much better sometimes when the camera is held close to the page. My head hurts after watching videos where less than half a page of work is shown in video and so the camera is constantly panning back and forth.  The same goes for videos sent to me in landscape orientation but with the page rotated...or upside down.  Students will be told to watch their videos before sending me the link.

3.) All phones must have notifications turned off while recording screencasts.  I'm listening to screencasts when the volume explodes with some random buzzing and I jump out of my skin. It is five freaking minutes that the text messages, facebook updates, tweets, emails, phone calls and instagrams can just be shut down.

Most of the complaints I have are about screencasts done using cell phone cameras.  I don't mind the use of the cell phone camera, it just seems more prone to the problem videos that I get.

March 30, 2013

On gender stereotypes, rocket science and the f-bomb

The above was retweeted by someone I follow this afternoon, and I was interested enough to follow the link to see what the minor uproar was about.

Reading the obituary, I learned a great deal about the contributions to engineering of rocket systems used in satellites and space missions made by an engineer who happened to be a woman. As so often happens when I read obituaries, I was a little sad that I did not know more about Yvonne Brill's accomplishments during her lifetime, but I do feel enriched by having learned something about her life and work.

Of course, the reason that the obituary was pointed out by Ed Yong was because it leads (lede? I'm not a journalist.) off with a stereotype of a women as a cook and mother. I take Yong's outrage to be that because this was first in the article, it must be assumed that we are to think that Brill was foremost a mother and wife and secondarily, therefore lesser, a scientist or engineer.

When people I respect link to other people that I don't follow on twitter, I do want to take them seriously. On the other hand, I have hesitations about engaging with people dropping f-bombs. The chance that the issue raised is too likely to be emotionally charged that I have a hard time judging rationally the actual content of the article.  In this case, I had to reread the article three times so that I felt I could honestly evaluate the problems with this article.

Here's the introduction to the obituary:
She made a mean beef stroganoff, followed her husband from job to job and took eight years off from work to raise three children. “The world’s best mom,” her son Matthew said. 
But Yvonne Brill, who died on Wednesday at 88 in Princeton, N.J., was also a brilliant rocket scientist, who in the early 1970s invented a propulsion system to help keep communications satellites from slipping out of their orbits.
Is there a way that it could have been written to be less offensive?  Let's try this:
She made a mean beef stroganoff, followed her husband from job to job and took eight years off from work to raise three children. “The world’s best mom,” her son Matthew said.   
Yvonne Brill, who died on Wednesday at 88 in Princeton, N.J., was a brilliant rocket scientist, who in the early 1970s invented a propulsion system to help keep communications satellites from slipping out of their orbits. 
That's better.  There's no need to include words like "but" and "also" when we're talking about people's career versus personal life.  The distinction should be obvious to any reader.

Can we make any other improvements?  What if the order of the first two paragraphs were switched?
Yvonne Brill, who died on Wednesday at 88 in Princeton, N.J., was a brilliant rocket scientist, who in the early 1970s invented a propulsion system to help keep communications satellites from slipping out of their orbits 
She made a mean beef stroganoff, followed her husband from job to job and took eight years off from work to raise three children. “The world’s best mom,” her son Matthew said.
I personally feel the argument that starting with the cooking and family life details is implicitly misogynistic to be a little weak. I had to read the article multiple times to make sure I wasn't missing something more than the opening paragraphs. By my count, 16 of the 22 paragraphs were about Brill's work, including being a woman in a male-dominated field. Is she not also entitled to be remembered for what she was like away from the office? By simply reversing the order of the two first paragraphs, the implicit framing of Brill as woman first, scientist second is removed, no doubt.  For me, that's enough to justify a claim that the obituary could have been better written.

But, can we take the outrage down a few notches?  Reading through the conversation following Yong's tweet, it seems that there is a "you're either with us, or you're against us" mentality. No doubt, there are some who just don't get what the outrage is about. Are we trying to raise awareness about how profiles of scientists can be framed in potentially harmful ways, or are we just looking to have outrage for the sake of outrage?

For me, I learned about the life work of a person I had never heard of, and I am grateful I now know a bit about her. But, it was also a reminder why I'm skeptical of emotionally charged tweets. In this case, I clicked through, and was please to learn about Brill. I might have just as easily decided to skip the article because of the language in Yong's tweet.  Frustrated or not with gender stereotypes, I don't believe that the science community is necessarily always better off with outrage as the default reaction.

March 04, 2013

Why I don't like the "Doppler Rocket"

It's time for me to rethink how we look at the Doppler effect in class.

When I'm working with a class on the physics of sound, whether it is a general physics class or a physics of music class, the Doppler effect is always one of the topics in whatever textbook we are using. Time permitting, we will look at the Doppler effect.  I think it's an interesting topic, and it certainly has important and useful applications in other fields of science: astronomy, medicine, weather, etc.

What I can't stand, though, is the terrible quality of the standard acoustic Doppler effect demos. I'm talking about the demonstrations where you take a sound source and tie a string to it, then whirl the string around your head with the sound source making a circle around you. The class is supposed to hear the change in pitch alternating between getting higher (while the source is moving toward them) and going lower (while moving away from them).

Unfortunately, the demo often has two major flaws with it:

1.) The change is pitch is often within the just noticeable difference (jnd) for non-ear trained musicians.

and,

b.) The change in pitches is almost always overwhelmed by the observation of the relative change in AMPLITUDE.  As the source moves away from the class, it seems to be less loud, and louder as it is approaching the class.

The situation is not much better when the demo is using a "Doppler Rocket" or "Doppler Ball" where a sound source is embedded in a soft ball then thrown or slid along a guide string across the room.  While it is usually the case that the frequency change can be more noticeable with these demos, since the speed of the ball can be high enough to make the frequency be outside the average jnd, my experience has been that the change in amplitude is even more dramatic with the Doppler Rockets.

What to do?  For me, it's interesting. I mean, one of the main ideas in science is that we only want to test one thing at a time. But in this experiment, we seemingly have two inextricably linked quantities that are changing.

I don't have a real good answer for what I want to do to get around these conceptual challenges. I've tried an Interactive Lecture Demo style presentation on the Doppler effect without the success I was hoping for.  I may try that approach again, but I'm sort of leaning towards making the Doppler effect a lab activity where students have to confront the two aspects of the experiment (frequency and amplitude) and tease them out separately.  I'm not sure if that will work at the introductory level, but I'm willing to try.

March 02, 2013

Weekend book review: The Radioactive Boy Scout

One of the first magazine articles I ever remember reading on the internet was the story of a teenager who wanted to build a nuclear reactor at his home. This was probably in 1998, during the thick of my time in college majoring in physics.  That time, as I recall, was before it was common to have magazine articles online. But Harpers Magazine was forward thinking, and the article was linked to from several nerdy websites that I read daily back then.

I learned about the concept of a breeder reactor, I learned that smoke detectors often used radioactive sources for their operation, and I learned that I wanted to know more about this story.  I was happy to hear that the author of the book had written a full-length book on the topic.

It took me awhile, but I finally got around to reading the book "The Radioactive Boy Scout" a few years ago.  I was not disappointed in the fleshing out of the story, although I was also not surprised that in parts of the book it felt like it was being padded to fill space.

The book was definitely a quick read, and it was worth going back to after years of first hearing the story. 


The Radioactive Boy Scout: The Frightening True Story of a Whiz Kid and His Homemade Nuclear ReactorThe Radioactive Boy Scout: The Frightening True Story of a Whiz Kid and His Homemade Nuclear Reactor by Ken Silverstein
My rating: 4 of 5 stars



View all my reviews




March 01, 2013

Is Marcus right? (Physics of the Funnies)

 

Here's another comic that I think could be used to spark discussion in a physics class. Some questions that I would want to elicit from my class:

How long is Marcus watching Jason fall?
What forces are on Jason?
How would we characterize Jason's motion? (constant velocity vs. accelerating)

Then, to go Mythbuster's style on the discussion: is the scenario plausible? Of course, it is a comic strip; it does not have to be plausible.  But, if it is not plausible, what conditions would have to be met to get the motion depicted in the comic?

Finally (for this post, at least): is Marcus right in what he says at the end?  Would using less helium make a difference?

February 28, 2013

Ancient astronomy

The above image is the first slide that I use to introduce the topic of ancient astronomy in my introductory astronomy course. It's something I put together a few years ago, and although I still sort of like it, I have a hard time remembering exactly what all the thumbnails are supposed to be representing.  As best as I can remember, the points I was trying to illustrate when I first put this slide together were:

1.) Many cultures around the world had at least rudimentary knowledge of the night sky, and in many cases had knowledge of astronomical alignments related to the calendar.

2.) We don't have time in class to talk about all of the interesting things that these cultures knew about. There is a LOT of interesting material that we could go into, but in the interest of getting to some modern astronomy topics, we have to pick and choose some ancient astronomy topics and leave the rest mostly untouched.  That's not to say that non-Western cultures did not know about or explore the cosmos.

From left to right in the above image, then:

The pyramid is El Castillo, also known as the Temple of Kukulkan located at Chichen Itza (not Chicken Pizza, as my tour guide told me when I went there a few years ago).  The temple is aligned such that on the equinoxes the sun casts a shadow over the steps of the pyramids which connects to the heads of serpents carved into the base of the steps. It's a pretty neat effect, and shows the Mesoamericans knew when the equinox would arrive and how to align the structure to accomplish the effect.  The Chichen Itza site also has what is thought to be an astronomical observatory on it. The tour I went on did not allow for a very close approach to the building, nor did the guide we have know much about that particular structure.

The middle image is (I THINK) a photo of the ruins of Babylon.  I do not believe that the particular image had any astronomical significance. Rather, I think I was trying to point out that many cultures in the middle east (Babylonians, Sumerians, Assyrians) at least attempted to understand the night sky. Clearly, I am not a historian, anthropologist, or archeology expert. I would like to know more about the ancient astronomical knowledge of the middle east.

On the right is a photo of a an armillary sphere at the Purple Mountain Observatory in China. This type of sphere was used by ancient astronomers to measure the position of stars in the night sky. What is not clear from the article that I linked to is whether or not the pictured instrument is an original or a replica.  I seem to recall that the armillary sphere at the Purple Mountain Observatory is actually a replica of the ancient instrument. I think that the replica is itself relatively old, but again, it's not clear from the page I linked to.

Maybe in the future I can dig up the original references I was using to piece together this slide.  For now, I'm happy with what I have.

February 27, 2013

Browser clutter - February 2013 edition

This is where I dump some links that I've had in my browser tabs for awhile.  I don't want to forget them, but I don't have a better place to put them.

Music inspired by astronomy - from the Astronomy Education Review.  I wish the pieces in the article had better links.

Inertia games - We have some REALLY OLD computers at school that we keep mostly to do this for algebra based physics courses.  If I could find a port of this to some new platform it might free up some space and time in the labs. (Alternative link)

Love2D - an open framework for making games.  Maybe could write an Inertia Games clone in this.

Over the winter break I was able to go to the national AAPT meeting and give a talk on the history of modal analysis.  I titled the talk something like "From Chladni to the present, a history of modal analysis".  In preparing for the talk, I was surprised to learn about a bunch of pseudoscience that has taken from the work done by legitimate scientists and applied to all sorts of nonsense.  At the risk of increasing traffic to their sites, I will point out some of the more laughable crap that I came across:

Harmonic Resonance Theory - weird.

Cymatics history - history of, uh, cymatics (whatever that is) "research".

"How the leopard gets its spots" - In 1988 Scientific American published this article, which may or may not be good science. All I know is that the inference that the modal analysis of a metal plate cut in the rough shape of a animal skin is related to how the patterns of spots appear in the animal's fur is just bizarre to me.  (Google search)

--END PSEUDOSCIENCE LINKS--

Making cloud chambers - I've tried this a number of times, and they never quite work for me.  :(

More links later!




February 26, 2013

What can you tell about this scene?

I'm going back into the archives for this comic strip. This is a "Rose is Rose" strip from January 22nd, 2007.  I like this strip not because there is anything wrong with the astronomy (as far as I can tell), but because I can use this comic strip to ask the following questions:

What time does the couple go out for a walk?

What direction are they walking?

More generally, depending on when I use this strip in class, I could ask: What can you tell about this scene?  Then, the class can discuss things like the time of day and/or the direction the characters are facing.

February 25, 2013

What, if anything, is wrong with this comic?

Image Credit: Creators Syndicate, originally published 5-30-2005
This is the first few panels from a Sunday "Wizard of Id" comic from several years ago.  I would like to use it as a "What, if anything, is wrong with this picture?" challenge for my astronomy students.

So: what, if anything, do you think is wrong with this comic?

February 23, 2013

A few blogs you're probably not reading, but should be

A few weeks ago, Brian Frank posted a link on twitter to a blog about PER that he thought many physics teachers might not know about. I wanted to point out some people that I really like reading that I suspect many people don't know about, either.

Patrick Len posts a lot of questions from his physics and astronomy classes and quizzes over on his blog. Some of the questions are peer-instruction style questions for use in class, but recently he's been posting questions related to current events in astronomy. He also posts a lot of useful materials for activities and demos that can be done in class.

Matthew Francis is a physicist now working as a science writer. I came across his blog, Galileo's Pendulum, when I was tracking down some information about a local science landmark. He writes about a wide swath of science topics, many of which aren't covered by other writers.

Dr. Drang is fairly well known in certain nerd circles. He remains anonymous online because his day job is engineering consulting for lawyers working on cases that may end up in court. He feels that keeping his online presence separate from his day job is the best choice for him. Nevertheless, he often posts really great stuff related to math, engineering and physics.

February 06, 2013

Python learning opportunity

I have an honors student this semester who is working on vpython simulations of general physics systems.  She knew no programming as of two weeks ago, but tonight was really close to having a projectile motion simulation done.

In trying to put velocity vector components on the projectile's position every 10 time steps, she was running into a problem: using the modulus operator only worked on the first two vectors, then did not.

Here was her code:

 while ball.y >= -2.75 and int_velo > 0:  
   rate(100)  
   t = t + dt   
   ball.pos= ball.pos + ball_velocity*dt  
   ball_velocity.y = ball_velocity.y - 9.81*dt  
   if (t*100)%10 == 0: #doesn't work!!!   
     vel_xvec = arrow(pos=(ball.pos.x,ball.pos.y,0), axis=(int_xvelo,0,0), shaftwidth=0.5)    
     vel_yvec = arrow(pos=(ball.pos.x,ball.pos.y,0), axis=(0,ball_velocity.y,0), shaftwidth=0.5)  

The comment tells the story. I guess I should know more about the modulus operator in python. It seems simple to use, but I couldn't really figure out what the problem was initially.

The short version of this story is that my student gets to learn about computer round-off errors and how to debug code by sticking a print command in the code so that she can figure out these problems without too much intervention on my part.

Here's my debug line I ended up using, followed by the fixed if statement:

   print t, t*100, (round(t*100)%10.0)  
   if (round(t*100)%10) == 0: #works now!!!   

I'm looking forward to a fun semester of python projects!

December 05, 2012

Some of my favorite astronomy images


Today was the last day of the semester in astronomy.  I showed three of my favorite images of all time as a part of our discussion of cosmology in class.  Presented with minimal comment, here they are:

This is the WMAP all-sky image of the cosmic microwave background. The difference in temperature across the entire sky as shown in the above map is less than 400 microKelvin!


The above image is the Hubble Deep Field.  This was taken in December 1995 after the Hubble images a patch of the sky that had apparently nothing in it. After 100 hours of exposure time, the assembled photo showed about 3000 distant galaxies. This image has reshaped how we view the universe.



This is an image taken by the Voyager 1 probe. The spot in the photo is what Carl Sagan refers to as the "Pale Blue Dot". It's what the rest of us call Earth.

I've shared this video that a student made for astronomy class before, but it's worth posting here again:


August 22, 2012

Is there value in self-promotion?

I'm trying a small non-scientific experiment tonight that you're a part of.

I've been struggling with the question of the value of linking to my blog posts on twitter.  It feels narcissistic to me to post every link on twitter.  Isn't anyone who cares about what I've written going to find my stuff in their RSS reader of choice or come back to the blog periodically anyway?  If my posts are good, they will get shared on twitter and/or facebook naturally, so I shouldn't have to link to them myself, right?

My primary audience is myself, so I shouldn't have to link to anything.  But, I do hope that somethings I say are useful, or else I would not bother to put them online. Plus, I know many people don't use RSS readers, and in lieu of the feed readers prefer to use twitter to discover blog posts.

So, I'm looking for thoughts from my loyal (also smart and attractive; did I mention I don't mind kissing up?) audience.  How do you prefer to find out about my blog posts?

Since this is a non-scientific experiment I am conducting, I will do the most non-scientific thing I can think of: state my hypothesis that I am testing.  ;)  My hypothesis is that my audience is too small (and smart, attractive and polite; there is no adulation I will not give out to you; I have no shame here, only on twitter) to give me any meaningful results of this experiment.

If I'm wrong, though, please feel free to leave me feedback via your preferred channel.

Thanks!

Think Like a Physicist - Introduction

The first time I ever taught an introductory physics course from top to bottom was as a last-minute summer replacement hire at small liberal arts college.  The schedule was intense: four hours a day every morning and two hours of lab 2-3 afternoons a week. I know I wasn’t the best classroom instructor, but we had a pretty decent lab and the students who took the class and worked hard did make it through, and most importantly they did learn some physics.

One issue that came up, though, about ⅔ of the way through the summer was that the students confessed that they hated the quizzes and exams I gave them, not because they were terribly hard, but because they felt like they could never guess what I (their instructor) was actually thinking when I wrote the question. At first I felt like my worst fears had been realized: that I had wrote confusing and impossibly hard problems. But after talking with them, I came to realize that the level of the questions had been appropriate, it was just that they were trapped in a way of thinking which led them to believe that if they could figure out what I was thinking, they would be able to figure out the answer to the questions.

My response was that the only thing I was thinking was that if they applied the physics principles which we had discussed in class, no student would have any trouble answering the questions.  Clearly, all of the students would breeze through the summer, all of them would earn an A for the course. Of course I was wrong.

I spent much the rest of the course trying to persuade the class that they did not need to be mind readers in order to do well. I’m not sure how many of them actually believed me, but the experienced had a profound effect on my teaching. Ever since then, I’ve tried to do my best to make the physics concepts the central focus of all the classes I teach. It has been a hope of mine that no student would waste any precious study time trying to divine what is going on inside my head.

But, as I looked back at that experience during the summer I first taught physics, I’ve been starting to wonder if maybe there was a lesson that I missed myself. What if the students weren’t so much trying to read my mind, but instead they were trying to think like me? Isn’t that what I wanted? The difference may be subtle, but important, I think. When students are trying to read my mind, they are looking at a problem or question and trying to guess what the professor WANTS them to say. When students are looking at a physics situation and trying to think like their physics professor, they are trying to apply the thought processes and analysis skills of a physicist.

That is exactly what I want from my students.  I want them to think like a physicist.

August 21, 2012

First online video assignment (for students to complete)

This assignment will be a little bit different than many of the video assignments I'm going to ask you to do this semester.

I want you to make a video using your hand as the moving object. Let the edge of a table or counter be the straight line along which your hand moves. The center of the table will be the s = 0 position. Positive position numbers will be to the right and negative position numbers will be to the left.

For each of the graphs below, I want you to interpret the position versus time graphs by performing the indicated motion with your hand. As you are executing the motions, explain all the details such as speeding up, slowing down, reversing direction, standing still, moving at constant speed, etc. You should have your hand at the appropriate position at t = 0 and at the end of the time history and be able to explain that, as well.

For each position versus time graph, sketch the corresponding velocity versus time graph and explain why the velocity vs time graph corresponds to the position vs time graph.


(Credit for this homework question goes to Arnold Arons. Credit for screencast/online video assignment goes to Andy Rundquist.)

August 14, 2012

A simple genetic drift simulation

Here's the tl;dr version of this post: I wrote a genetic drift simulation that you can download and play with if you want.

When I was in high school, I had a really great teacher for biology. That's not just me saying that; she won awards at the state level honoring her as a great teacher. I don't remember all the topics that we covered in that class, but I do remember that she took me on a tour of the brand new (at the time) microbiology facility at Iowa State University. Besides being a really shiny building, it was the first time I had ever seen biology being done with computers.

Last year when I started teaching at the community college, one of the biology professors said he wanted a genetic drift simulation. He explained what he was looking for, and I nodded politely, only vaguely following along. (That's physics training, for you.) After I read a bit about genetic drift, I found an example of a very simple genetic drift simulation activity. I thought something similar would be doable in python.

Here's the user interface for the simulation:

 It is extremely basic.  All you do is choose the size of your population and the number of generation that you wish the simulation to run for.

Here is an example of a small population run for 100 generation:


As you can see, this simulation started with the Q (recessive) allele making up 70% of the population.  The P allele is quickly wiped out of the population.

Here is a simulation of a much larger population:


For a large population the simulation will start with a much closer match between the P and Q alleles. It was almost 50/50 in this run. And, after 500 generations neither allele has been eliminated, although the Q allele is starting to have a significantly higher fraction of the population.

Here's a snippet of the code that does the actual simulation part.  The mechanics of the simulation is explained in the comments:

--
--

I like this because 1.) It quickly shows the difference between genetic drift for large and small populations, and 2.) the simulations start with random conditions and have random progressions, but over a large set of simulations clear patterns emerge. I could envision a class of students running the simulations multiple times each, then compiling the data together into a class set where more conclusions are drawn.

Hopefully my code is expandable.  I'd like to add features, such as setting the initial populations, selective processes, and possibly multiple traits.

In case you want to try this (PLEASE TRY IT and give me feedback) you'll need: python, matplotlib, numpy, and Qt runtime libs.  Maybe you'll need more, I'm not really sure.  I needed coffee when I was working on it.  YMMV.

August 10, 2012

Getting information from students - Fall 2012

Hat tip to my source of many awesome things - a local high school teacher - for this idea.  Instead of students filling out an index card of information so I can get to know them, I have them fill out a form which I create in Google Drive. I post the form to the course web page, then point them there.  This way, all the information is in a spreadsheet which I can review anytime throughout the semester from anywhere.

I added the question about the smartphone this year to try to get a sense of how much I can try to get get my classes to do interactive things with them. 

The form is below...(for now)...it's not the real form, but it is a copy of the one I'll put out on the course page.

-------

Acceleration data of a (hypothetical) airplane

Hypothetically, if one were to be on an airplane in possession of a smartphone with the right app, one could hypothetically gather acceleration data of the planes motion.

I (hypothetically) was on a plane earlier this summer and (hypothetically) had my phone in airplane mode running the data gathering program with the display off until the plane landed and reached the gate.

My phone has a 3-axis accelerometer built into it.  The figures below show the orientation of my (hypothetical) data gathering.







I figure that I should (hypothetically) let the data gather for 5 minutes and hope that the landing happens in that time.  After starting the data logging app, I turned off the screen and set the phone on the floor by my feet.

Here's the acceleration data:



In the z-direction, you can see the setting down and picking up of the phone at the start and end of the graph. (Note the full 5 minutes was not used.) The acceleration is fairly constant around -10 m/s^2, due to the gravitational field.  What was interesting to me was that the average value before the (hypothetical) touchdown was the same as after touchdown, although definitely not as smooth.



In the y-direction you can again see setting down and picking up the phone, as well as the (hypothetical) landing event. There is an acceleration in this direction as the plane turns to head towards the gate.


But what we really care about is whether or not this plane is going to stop moving at a high speed in the forward (x) direction.  The acceleration data here is interesting! The maximum acceleration is about -3 m/s^2.  There are several braking events which happen.  Does constant acceleration apply here? Over certain intervals the acceleration is approximately constant, but not over other intervals.

Now I know what the acceleration of a plane landing is (hypothetically) like.  Want the raw data? Here you go. Hypothetically, I would like to know what the acceleration of a plane is like on take-off, but I don't have another (hypothetical) plane trip scheduled for awhile.

Always follow the instructions of your flight crew. You don't want to pick that fight. You will lose.