Flipping the classroom: creating screencast lectures in Linux

I’m debating the idea (hype) of flipping the classroom for one of my classes next Fall where students watch lecture videos at home (or elsewhere) so I could spend class time doing more hands-on activities like discussing the art of data analysis and how to solve problems with statistics. I think Khan Academy, Udacity, and Coursera are doing a great service for humanity by offering high quality courses taught by excellent teachers online that are accessible to anyone with an internet connection.

I don’t claim to be a great teacher, but I think my own students might benefit from this pedagogical method. My main concern with this approach is that not all students will watch the lectures, just as how not all students read the assigned readings (guilty as a student). I guess I can give students short quizzes during lecture to push them to watch the videos. Also, I’ll give my usual challenging homework so that only students that study the material well could excel. By flipping the classroom, more material could be covered, students have access to the recordings in addition to my slides, and I could make sure everything I want to be said are recorded (as opposed to a live session where I could forget a few points). Lecture times can then be more interactive as opposed to me lecturing them for an hour.

I think most of the online education sites use Camtasia with a Wacom Cintiq to produce their videos. I use Linux and cannot afford such an expensive device. I plan on using a screencast software like recordMyDesktop or Istanbul to record the desktop screen and audio. For recordMyDesktop, I had issues with the encode on the fly option, which means recording very long videos could be an issue (1 minute of raw video takes up about 210MB, and 1 minute encoded video takes up about 8MB). Istanbul records on the fly without problem (I think). I haven’t tried recording for an hour and 20 minutes yet.

My plan is to create my lecture slides with LaTeX Beamer and use Xournal to annotate the slides as I’m lecturing; hopefully my Asus T101MT netbook is strong enough to do the recording as I utilize it’s touchscreen capabilities. I can just switch over to Emacs to illustrate data analysis in R when needed. My main concern now is where I could host these (large) videos…

Update 4/27/2012: Screencast with ffmpeg

After some testing, I think the best screencast software on Linux would have to be ffmpeg. First, remove ffmpeg and compile it from source based on the latest version per this post. Then, create screencast.sh:

#! /bin/bash
DATE=`date +%Y%m%d`
TIME=`date +%Hh%M`
ffmpeg -y -f alsa -ac 2 -i pulse -f x11grab -r 24 -s $(xwininfo -root | grep 'geometry' | awk '{print $2;}') -i :0.0 -c:v libx264 -preset veryfast -crf 22 -c:a libmp3lame -ar 44100 -ab 24k -threads 0 /tmp/screencast_$DATE-$TIME.mp4

For more libx264 options, see this page.

Teaching with a graphic tablet and a projector: replacing a whiteboard or overhead projector

Many times when I teach, I often want to keep a copy of what I write on the board. Why? I can have a softcopy to refer to when students have follow-up questions, I can re-use these notes for the next discussion if there are only a few people, and I can re-use them in later quarters. In high school, I always liked the overhead projectors. Teachers can write and look get feedbacks from the students face to face. Also, you can just scroll your super long sheet up as you write and not worry about erasing like on the white board. Later in lecture, you can pull them back if you want need to refer to the previous notes. I always had an idea to use some kind of a tablet device with the projector, which all modern classrooms should have. I finally decided to buy a fairly inexpensive Genius graphic tablet from Walmart for $40. Wacom tablets are probably better, but they are very expensive, especially the larger ones. I guess they are expensive because they are meant to be used with photoshop by artists. In my case, I need a large tablet but it doesn’t have to be premium since all I’ll be doing is writing words and math symbols on it. My platform is a Mac OS X, and this link discusses some tablets and programs. This site discusses the tablet PC’s use in the classroom altogether. After some trials, the best program seems to be inkbook, which costs $40. However, I guess the Genius driver doesn’t play well with inkbook. To get it to work, I have to turn on “Handwriting Recognition” in System Preferences > Ink. In Inkbook, i can write in the ink mode. I see a yellowpad whenever I write. This SHOULD NOT be there, but it works for now. Wacom would play nicer. Update 3/27/2010: I returned the Genius tablet a few weeks ago as it does not play nice with inkbook. The author recommended a Wacom. However, it is too expensive for me (a decent sized one) and I won’t need one yet since I don’t need to TA next quarter. Hopefully, the Apple Ipad will have a pen with it so I can use it with this (main reason I would buy one). Otherwise I would have to consider getting a cheap netbook with a pen.

plots: chemical structure diagrams

For some reason I’ve been wanting to learn how to make chemical structure diagrams. I have no use for them, but I just want to know how to draw them on the computer. I found out the programs that make such diagrams are called “molecule editors.”

A quick search yielded a lot of proprietary software, but a few open source (free) software popped up as well. I like BKChem because it is python-based and hence platform-independent. Who knows, maybe I’ll teach/tutor chemistry one day, or maybe I’ll collaborate with a chemist. BKChem might come in handy then.

Getting information and learning: google + wikipedia + wikibooks + wolfram alpha

When I want to find information, Google is my #1 resource. The syntax trick I use most which I learned in the research writing class (Writing 39C) at UCI is “The first word is the most important” (the first word narrows the search!). Some other tricks are “- Don’tWantThisWord” and ‘ “this quote exactly” .’ Google usually leads me to Wikipedia, an online collaborative encyclopedia, or Wikibooks, an online collection of collaborative textbooks, for my answers. These three resources are where a lot of my learning/review of statistics are found.

There is Google Knol but I don’t use it much (probably because my google search doesn’t yield these articles).

For academic articles, I search on google, but to restrict the results to just academic articles, I’ve been relying on Google Scholar.

Last but not least, Wolfram Alpha was recently released by Wolfram, the maker of Mathematica. Haven’t used it much, but it seems promising. The few reviews that I’ve read said that the search is a little tricky…you have to input the right words. Well, they’re not google afterall.

Animation / Interactive plots in R for inclusion in html websites or latex documents (beamer)

http://blog.nguyenvq.com/wp-content/uploads/2009/05/Consistency-Ani.gif

http://blog.nguyenvq.com/wp-content/uploads/2009/05/CI-animations.gif

http://blog.nguyenvq.com/wp-content/uploads/2009/05/sinTaylor.gif

Been wanting to do an interactive/animated plot like the one here for a while (go to the Taylor example). Sage looks like a good program to generate animated graphics, but R is my primary language of choice as a statistician. I don’t want to learn another language just for a single feature (although the other features look good as well). For mathy stuff that require the likes of Mathematica (cannot be done in R), I’ll go to Sage. But for now, I’ll stick with R.

Check out the animation package in R and check out the examples here. It’s quite easy to create animations in R. Just create a series of plot (in png or jpeg format) and make them interactive via the convert command from ImageMagick to pack them into a gif file. We can also use mencoder to turn a series of plot into an avi file or convert to turn them into an mpeg file for inclusion in LaTeX documents or slides.

Some code:

<pre class="src src-R"><span style="color: #7fffd4;">library</span>(animation)

setwd(“~/Documents/UCI/RWorkAndExamples/”) storagefolder <- ‘Animations-CI’ if( !(storagefolder %in% dir()) ) dir.create(storagefolder) outfolder <- file.path(getwd(), storagefolder) oopt <- ani.options(interval=.05, nmax=100, outdir=outfolder, ani.type=“jpeg”, ani.dev=jpeg, filename=‘CI-Animations.html’) ##store old options first ani.start() conf.int(0.95) ani.stop()

##addprefix script:
#! /bin/bash
addtofile='prefix';
for file in $@
do
mv $file $addtofile.$file;
done
echo "Now run rename to change prefix."

##run in shell ##vinh's script addprefix *.jpeg rename prefix. 00 prefix.?.jpeg rename prefix. 0 prefix.??.jpeg rename prefix. 00 prefix.?.jpeg rename prefix. "" prefix.???.jpeg

Check out following this and this to convert image files into movies (for inclusion into pdf via multimedia or movie package):

<pre class="src src-sh">mencoder <span style="color: #ffa07a;">"mf://*.jpeg"</span> -mf <span style="color: #eedd82;">fps</span>=5 -o CI-animations.avi -ovc lavc -lavcopts <span style="color: #eedd82;">vcodec</span>=msmpeg4v2:<span style="color: #eedd82;">vbitrate</span>=800

Check out this to convert image files to gif animation for use on websites:

<pre class="src src-sh">convert -delay 50 -loop 50 ??0.jpeg CI-animations.gif

##check following
saveMovie(expr={for(i in 1:10) plot(rnorm(100))}, outdir=outfolder)

ani.options(nmax=100) saveMovie(expr=clt.ani(obs=300), outdir=outfolder) flip.coin()

###Taylor example ifelse1 <- function(test, yes, no) if(test) yes else no

sin.taylor <- function(x) x - x\^3/factorial(3) + x\^5/factorial(5) - x\^7/factorial(7) sin.taylor2 <- function(x, n=NULL){ if(is.null(n)) sin(x) else{ x +ifelse1(n>=3, - x\^3/factorial(3), 0) + ifelse1(n>=5, x\^5/factorial(5), 0) + ifelse1(n>=7, - x\^7/factorial(7), 0) + ifelse1(n>=9, x\^9/factorial(9), 0) + ifelse1(n>=11, - x\^11/factorial(11), 0) } } curve(sin, xlim=c(-2pi,2pi), ylim=c(-2,2)) x <- seq(-2pi, 2pi, .1) lines(x, f.taylor(x), col="blue", lwd=2) lines(x, f.taylor2(x, n=7), col="blue", lwd=2)

jpeg("sinTaylor%03d.jpeg") for(i in c(1,3,5,7,9,11)){ curve(sin, xlim=c(-2pi,2pi), ylim=c(-2,2), main=paste("Taylor Expansion of f(x)=sin(x)\nOrder = ",i)) lines(x, sin.taylor2(x, n=i), col="blue", lwd=2) legend(4,2, legend=c("f", expression(hat(f))), lwd=c(1,2), col=c("black", "blue"), bty="n") } dev.off() ##shell: convert -delay 100 -loop 50 sinTaylor00?.jpeg sinTaylor.gif mencoder "mf://sinTaylor00?.jpeg" -mf fps=1 -o sinTaylor.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800

##consistency n <- 200 x <- runif(n, 0, 4) y <- .2*exp(x) + rnorm(n,2) jpeg("Regression%03d.jpeg") plot(x,y, col="red") fit <- lm(y~x) abline(fit, lwd=2, col="blue") dev.off()

set.seed(123) jpeg("Consistency%03d.jpeg", quality=50) n.seq <- c(10,20,50,200,1000) nsim <- 4 for(i in 1:length(n.seq)){ n <- n.seq[i] for(j in 1:4){ x <- runif(n, 0, 4) y <- .2exp(x) + rnorm(n,2) plot(x,y, col="red", xlim=c(0,4), ylim=c(-1,15), main=paste("n =", n), cex.main=2) fit <- lm(y~x) abline(fit, lwd=4, col="blue") legend(0,15, legend=paste("Slope =", round(fit$coef[2],2)), bty="n",cex=2) } } dev.off() ##shell convert -delay 100 -loop 50 Consistency0.jpeg Consistency-Ani.gif mencoder "mf://Consistency0*.jpeg" -mf fps=1 -o Consistency-Ani.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800