32
Adventures in using R to teach mathematics Paul G. Bamberg Senior Lecturer on Mathematics Harvard University O P E N D A T A S C I E N C E C O N F E R E N C E BOSTON 2015 @opendatasci

Adventures in using R to teach mathematics

  • Upload
    odsc

  • View
    68

  • Download
    2

Embed Size (px)

Citation preview

Adventures in using Rto teach mathematics

Paul G. BambergSenior Lecturer on

MathematicsHarvard University

O P E ND A T AS C I E N C EC O N F E R E N C E

BOSTON 2015

@opendatasci

Prologue – Data Science in the 1980s

• Given recordings of several thousand English words and the phonetic spelling of each word, build an acoustic model for each phoneme of English in each possible phonetic context.

• Given electronic versions of several years of the Boston Globe and other text, make a table of the frequency of occurrence of all pairs of English words.

• The result: DragonDictate for MS-DOS, with a 64,000 word vocabulary, running on an Intel 80286 processor.

Act I

• You can fool almost all of the people almost all of the time.

• Bob Marley• Mathematics E-156, Spring 2014• Prerequisites

Why choose open-source software?Misadventures with the alternative:

• Windows GUI programmingMicrosoft Visual C++ 6(taken off the market in favor of .NET)

• Linux GUI programmingRed Hat Linux(versions for individual use discontinued)

• Computer algebraMathematica(free, but only for enrolled undergraduates)

The mathematical side

• Proof of the week

R Scripts for Lecture

• Exploratory Data Analysis• Support for a Proof• Confidence Intervals• Beta Distributions for Bayesian Analysis

Homework is submitted as R scripts

• Sample Homework Problems

Midterm and Final Projects

• Analysis of Demographics and Socioeconomic Factors of Countries

• Analysis of Gene Expression Data • Analysis of Global and National Data on Public Health

Issues of Substance Abuse • Analysis of IT Satisfaction Survey • Experimental parameters in high-throughput gene

expression • etc………

Was the course a success?

• Evaluation results• “Very rigorous treatment of material. The R

scripting gave useful examples that can be applied to real world problems.”

• “The use of the R Programming Language in understanding key statistics concepts really helped. Doing the homework manually (as opposed to using the built-in methods) was extremely helpful in my understanding of the core concepts.”

Act II

• Summer School is Y-coming in• National Youth choir• Mathematics S-323,Harvard Summer School• Course description

Use of R in Math S-323

• No statistical functions!• No data frames!• Much use of built-in vector operations• Diagrams for geometry and trig.• Inversion and row reduction of large matrices.• Spherical geometry (fascinating, but

computationally messy if done by hand).

Scripts used during lecture

• Points and vectors• Matrix for a Markov Process• Theorem of Menelaus

R scripts in problems

• Students broke up into three teams of four to solve these problems during class, then each team uploaded its solution to the Web site.

• Three problems from day 2• Solution to problem 3• Solution to a problem on the midterm

Was a math course with R OK for high-school math teachers?

• Summer School evaluations

Act 3

• What is sauce for the goose may not be sauce for the gander.Math 23a/E-23a, Fall 2014

• Irish Chieftains

If Harvard freshman mathwere football instead…

• Math 55a = All-Americans• Math 25a = Starters on the varsity• Math 23a = May get to play two minutes in

the Yale game if Harvard is way ahead• Math 21a = Intramural sports• Math 18 and 19 = Just spectators

A week of Math 23a materials

• Samples from Week 4

Perhaps R will go viral on YouTube

• Introductory script on eigenvectors

Using R to present a proof

• Georg Cantor's proof that the real numbers between 0 and 1 are an uncountably infinite set

Using R to do real analysis

• The Bolzano-Weierstrass theorem: on a closed interval, every infinite sequence of real numbers has a convergent subsequence.

Using R to explain divergence and curl

• Derivative of a vector field

Was a math course with ROK for Extension students?

• Math E-23a evaluations

Was a math course with ROK for Harvard freshmen?

• My worst evaluations in 15 years

Is the difference in evaluationsbetween adult learners and freshmen

statistically significant?Permutation test on the data

Conclusion: the probability that such a large difference between Extension and freshman evaluation scores would arise by chance is less than 1%.

How could this course be improved?

• Less use of R would facilitate better understanding of the material.• The R-scripts, while beautiful and illustrative, were not extremely helpful .• Get rid of R for lecture. • Maybe less use of the R studio. Many students don't like using R. • I think this course might be improved by relying way more on pencil and

paper to explain material than by relying on R. • R was a good addition to the course (esp. on homework) ... but too much

lecture time was spent on it. • The use of the programming language R is superfluous and hinders

understanding of the material. • The R coding element is great for demonstrations, but is tedious when on

problem sets.• etc…… The message is clear.

One Extension student’s interpretation

• “Most students in this class were freshmen and their entire experience with math is stuff they can do by hand. They want to just know how to do it and then solve the problem and get an answer. But I can't think of a single job the students would have in the future where they'd be doing math by hand. You absolutely need to know how math can be done through programming to solve hard problems. Those are super marketable skills -- row reducing by hand is not. I certainly didn't know or appreciate this as an 18 year old. I do now.”

Act 4

• Did I throw out the baby with the bathwater?• Math 23b/E-23b, Spring 2015• Eddie Burns

Clap if you want to save Tinker Bell

• Email to the class: no R scripts during lecture in Math 23b.

• I emailed all the students who had done term projects in R to let me know if I should make YouTube videos of R scripts for Math 23b and if they wanted optional homework problems and term projects using R. Only a handful replied.

A survey with a 100% response rate

• For 1 point on the final exam: what did you like better in the fall than in the spring?

• “R was an opportunity to visualize concepts.”• “I thought the use of R was quite effective in the fall term.”• “Learning R to do the problem sets was a useful skill and I wish I’d done

more of it.”• “Extra credit R project was good. R for extra credit is ideal.”• “Using R with concepts of real analysis helped me visualize limits better.”• “Concepts were made clear through the use of R for in-class

demonstrations, particularly those in need of heavy computation. R also allowed application examples to be done in lecture.”

Spring term evaluations

• Freshmen: up by 0.4• Extension: up by 0.2• Under “strengths of the course:”• “No R scripts.”• “I’m so glad there was no R.”• “Not using R made Math 23 so much better.

Tentative conclusions

• With students who know they are going to be using R professionally, lectures based on R scripts are effective and well received.

• Non-programmers like R for visualization and eliminating tedious computation, but explaining scripts line-by-line is a no-no.

• For presenting R scripts, YouTube is as effective as a live lecture.

• Homework problems that only require modifying existing R scripts can be done by anyone.

You can do this next year

• Math E-23a and Math E-23b will be offered again, and for the first time there is an online-only option. R is used only for linear algebra.

• Math S-323 starts on June 20.• I am looking for a statistician with teaching experience to

take over Math E-156. Email a resume to [email protected] if interested. If no one applies, I will probably teach the course myself Wednesdays 5:30-7:30 in the spring.

• Harvard Extension School offers a graduate certificate in data science.