Thursday, August 8, 2013

Everybody’s Coding: A critique of math education and new tools for computer-oriented learning





HCESC Tech Academy August 8, 2013
Talk by Fred Annexstein, University of Cincinnati




The next ten years present an important turning point in mathematics and technology K12 education. Will computers be an integral part of standard K12 education? Will computer science be an essential and mandatory part of every high school curriculum? Will high school mathematics curricula be refactored to take advantage of the calculation and visualization powers afforded by modern tablet computers?

The technological world has changed dramatically in the last 20 years. However, as a professor of computer science at the University of Cincinnati, I have seen little change in the skill set of incoming freshman. Math and quantitative literacy are certainly among the most important skills that new students bring to their higher education institutions. However, when reviewing standard middle and high school mathematics textbooks, I see a disconnection from my world-view as a working professional in mathematics.

All our futures are now tied to the advances in computing, and the math, logic, and software that defines computation. Therefore, much is to be gained by addressing the role of computers and math in K12 curriculum directly. Articulating the design of a mandatory curriculum that integrates math, digital literacy and computer science, can and will have a positive impact on individual students, and have a significant impact on society as a whole.

First, there is the economic impact associated with having a better technically trained and scientifically educated student body. The demand for tech skills in the modern workplace is well documented. (A sense of the scale of the demand is reflected in the fact that there are currently 3000 unfilled IT and Computing jobs in the Greater Cincinnati area.) Second, there is the intellectual impact associated with understanding the scientific significance of computers, statistics, and information theory, which is accessible to every high school student. Third, there is the emotional impact associated with the feelings of freedom and the joys of discovery that can emerge from young people through interaction with and control over technology. Fourth, there is the cultural impact associated with a tech knowledgeable and civically engaged citizenry. There is no doubt that to understand and engage with issues of cybersecurity and NSA surveillance, for example, one needs to know how computing system such as PRISM and XKEYSCORE work, and this requires a basic understanding of computers and their design.

On the other side of the fence are those who prefer to avoid going down the route to integrate computers and computer science into standard K12 curriculum. One argument on this side is that for most careers domain knowledge is more important than computer coding skills, and most people will not be coding directly, even if students will likely be using modern computers in the workplace of the future.  Another set of arguments against integrating technology in schools has the effect of “ghettoizing” computer coders into an elite class of mathey nerds, often with a prejudice that coder culture is exclusive, puerile, and male.

Deep Digital Literacy

To achieve any level of depth in digital literacy, students must be able to learn and produce computer code. This digital literacy extends into quantitative, math and science literacy and has the potential to bring the curriculum of those subject areas up to date and present them in a context that would be more recognizable to a modern working professional.

Concepts of the Internet
To deeply understand the Internet and the World Wide Web a student needs some coding skills. The Internet is coding “all the way down”, from front-end technologies such as HTML, Javascript, CSS, to the back-end technologies such as SQL, Linux, Windows; from the specs and protocols running the worlds networks such as HTTP, TCP, FTP, to the mobile applications running the modern economy such as Android, iOS, Gmail, Twitter and Facebook, and the scripts and programming frameworks that glue it all up together such as Ruby, Python, Java, C++, Perl, ObjC.  Of course, a student could only learn a small fraction of details of the coding architecture of the web, however understanding its overall design and underlying principles are within the grasp of every student.

Concepts of Physical Simulation
Physics and engineering in the real world is understood through numerical simulations performed by computers. This is the real math, and why math is important, and how math gets done. High school math curriculum that focuses on hand-calculations at the expense of avoiding a focus on this real-world math is doing students and society a disservice.

Concepts of Information Science
The digital age begins with the theory of information science created by the pioneering work of people such as Alan Turing and Claude Shannon in the 1930s and 1940s. The concept of the algorithm, the universal machine, entropy, encoding and decoding information—this is the foundational science part of the digital age. Turing’s breakthrough idea was that computer code is universal, that is to say, anything that is possible to compute is possible to compute with a very simple machine and an algorithmic idea expressed in a form appropriate for that machine.  Turing’s genius is still underappreciated today. James Gleick’s book “The Information: A History, a Theory, a Flood” presents this new science of information through engaging biographies, such as those of Turing and Shannon.

A visionary who took early note of the power of computers in science and math education was Seymour Papert.  Professor Papert is credited with an influential theory on learning called constructionism, and he states, “The role of the teacher is to create the conditions for invention rather than provide ready-made knowledge.” In his seminal book “Mindstorms: Children, Computers, and Powerful Ideas” (1980) he speaks on the revolutionary impact of project-based student work using computers.

The Problem with Algebra

“Is Algebra Necessary?” is the title of a provocative NY Times opinion piece by Andrew Hacker that was published July 28, 2012, and has provoked over 500 comments and many blogs. Hacker argues that when legislators require that “every young person should be made to master polynomial functions and parametric equations”, then they are missing the point of quantitative literacy. Educators are trying to respond to a looming crisis in which there are math education mandates and widespread dislike by students and other stakeholders for the current state of curricular affairs. A number of educators have suggested that introducing computers can address some of these issues, but in most states computer science is an elective that does not satisfy any math requirements. The quantitative literacy of American students is under scrutiny, and traditional algebra courses do not seem to add up.

To get a sense of the disconnect in K12 math affairs, let us consider a well regarded textbook and curriculum provided by SaxonMath, published by Houghton Mifflin Harcourt. The principles underlying the design of SaxonMath are that it provides “Consistent Lesson Structure” and “Distributed Units of Instruction.” The motivation being that a consistent structure provides teachers with a “predictable routine” in the classroom, and the distributed practice claims to “provide students with depth of understanding”. The curriculum is divided into many dozens of micro-lessons with topics changing on a daily basis. Topics are shuffled in and out through the year.

For example, here is a selection of three contiguous micro-lessons from Saxon Algebra 1, which would probably be covered in one week in an 8th grade classroom setting:
*Lesson 12 – Using real numbers to simplify expressions
*Lesson 13 – Calculating and Comparing Square Roots
*Lesson 14 – Determining the Theoretical Probability of an Event
The textbook continues in this way covering over 120 micro-lessons.

Each of these micro-lesson topics is, of course, on its surface very important to mathematics education. But where do we see any “Big Ideas?” How do all these shuffled lessons fit together into a coherent picture of mathematics? And how do students react to the material? Do students reflect on the material beyond the fact that “math is too hard for me,” or “math is an easy A!”? We should desire and celebrate situations where a student says, “Hey, I can do that problem easier on a calculator or computer.” Recognizing when a problem is in a form ready for calculation by code reflects depth of understanding. A student who understands some simple ideas of computer math, e.g.,  a computer algorithm to calculate square roots and code that can estimate theoretical probabilities would be far better equipped for today’s world.

A recommended online resource is a TedTalk entitled “Stop Teaching Calculating, Start Teaching Math” by Conrad Wolfram in which he advocates for a new math curriculum based on using computers for calculation (see website http://computerbasedmath.org ). Wolfram indicates that math is a four step process: 1) posing the problem, 2) formulating in mathematical language, 3) calculation/computation, and 4) verification. He suggests that currently 80% of student time is spent in doing step 3 using hand calculations, whereas ideally computers should be used to free students to devote more time to other steps. Students can achieve greater depth of understanding when curriculum is directed at formulating and modeling problems mathematically. Recently, efforts in this direction have been adopted by some European nations, thus far focusing on statistics curriculum in high schools, with potential to expand to other math grades.

A Project-Based Curriculum using Computers and Coding

High school students must become familiar and comfortable using computers as calculation engines. At the start of such an endeavor, there are great benefits to giving students an artistic experience with technology. Such experiences can strengthen students, giving them self confidence, and can work against the more harmful effects of technology in the modern age.  One curriculum idea that I have worked with in the setting of an 8th Grade classroom is to use modern software on laptops that provide a platform for students to become “Algorists.” An algorist, or algorithm artist, is someone who uses computer coding to generate artistic media, images, sounds, etc. Much more than cut and paste is expected here, and students really create their own art works. This fits the need for middle schoolers to experience self-reliance and supports their inclination to create their own media.  There are several actively supported computing platform tools to help students achieve this goal. There are very good Java and Python media computing textbooks that support introduction of computer science concepts, such as Barbara Ericsson’s and Mark Guzdial’s (Georgia Tech) An Introduction to Computing and Programming with Java: A Multimedia Approach (2006).

Computer gaming is an excellent way to both engage students and to introduce physical simulation. The mathematical modeling of gravity, the science of falling and projected bodies, and the algebra of force vectors are all well motivated in computer games and animations. There are several low-overhead entry points for students and teachers to begin working on computer physical simulations.

Scratch/TurtleArt – TurtleArt and Scratch are applet based art-programming environments, Both can be used by young students to generating images using turtle commands, such as move, turn, and pen down. Scratch has been designed with “wide walls” allowing the popular platform to be used for many purposes. In these friendly environments, students program by snapping colorful code fragments together like Lego building blocks. Scratch is excellent choice to use to support digital literacy, digital design, and when introducing basic computing concepts like variables and flow of control (see, http://scratched.media.mit.edu/ )

Linux/Python/Perl – It is relatively easy, using these technologies, to set up a command line (non proprietary) environment that gives students more control over the processing power of the computer. Python and Perl are languages that can be used to provide an important functional programming environment, one that is used successfully by students to do powerful text and media processing.

Processing - Processing is a programming language designed to promote software literacy within the visual arts and visual literacy within technology. Initially created to serve as a software sketchbook and to teach computer programming fundamentals within a visual context, it is now very mature software and exciting for more advanced students.

Here are some final thoughts: Technology moves very rapidly, and computer languages and platforms come and go with increasing frequency. Teachers must give up on being gatekeepers to tech knowledge and focus efforts on mentoring in a tech culture. The focus of education should be on creating environments where students care really “see” math in action and building school cultures where self-assured students armed with computer lab or simple tablet and an ability to code can meet important challenges of science and technology straight on.





Handout for talk on “Everybody’s Coding”
Mathematics/Computer Science/Technology - Resources for K12 Education
By Fred Annexstein, University of Cincinnati, fred.annexstein@uc.edu

“The context of human development is always a culture, never an isolated technology." - Seymour Papert, mathematician, computer scientist, educator, founder of MIT Media Lab.

Inspiring TED Talks:
*Mitch Resnick: Let's teach kids to code: http://youtu.be/Ok6LbV6bqaE
*Conrad Wolfram: Teaching kids real math with computers: http://youtu.be/60OVlfAUPJg


Supporting Websites:
*Computer Science Teachers Association: http://csta.acm.org
*Computing at School (UK): http://www.computingatschool.org.uk/
*Code.org: http://code.org
*Mark Guzdial’s Computing Education Blog: http://computinged.wordpress.com

Curriculum Resources:
*UK K12 Computing Curriculum:


Supporting Platforms and Tools:
*Scratch  / TurtleArt  “visual programming using legos” http://scratched.media.mit.edu/
*Processing  “software literacy within the visual arts “  http://www.processing.org/
*Alice  “OO programming in 3D environment” http://www.alice.org/
*Code Academy “learning in web-based javascript  environment” http://www.codecademy.com/
*Linux Environment for Education: http://www.edubuntu.org/
*Microsoft Dreamspark “MS software for students and educators”







Tuesday, July 23, 2013

Reflections on Binghamton, Harpur Jazz Project, and Great 80s music

I lived for six years 1979-1985 in Binghamton NY attending SUNY and enjoying life listening to lots of music. There was a great radio station WHRW-FM on campus with an amazing music librarian named Ron Drumm. Mitch Goldman ( http://mitchgoldman.com/bio.htm) worked at the radio station and chaired a student group called Harpur Jazz Project. HJP brought so many excellent shows to campus, bringing many jazz giants up from NYC so happy to come up to Bing for the people.

Working with this group I was fortunate to meet and share meals with many legends of the jazz world. My wife Lori and I would often acted as hospitality hosts, cooking vegetarian meals for the musicians. Some complained about menu, but most graciously appreciated our offerings. I recall Vernon Reid of Living Colour being particularly appreciative of the veg-spread. Here are some of the folks we had the pleasure to meet:

Sonny Stitt, Jo Jones, Louis Hayes, Slam Stewart, Jane Ira Bloom, Doc Cheatham, Julius Hemphill, Oliver Lake and Jump Up, Hamiet Bluiett, David Murray, Defunkt, James Blood Ulmer, Ronald Shannon Jackson, Billy Harper, Steve Turre, Jack DeJohnette, Harold Mabern, Ricky Ford and his Big Band, Jaki Byard, Vernon Reid and Living Colour, Rhys Chatham, Pat Metheny, and many, many others.

Recalling the good times and the great music of the 80s.....



Sunday, April 1, 2012

Visualizing Musical Intervals and Harmonies using Matlab Figures



Visualizing Musical Harmonies

In this post we consider the issue of providing a visual interpretation of musical harmonies. Our approach is via
the simple model of Lissajous (“LEE-suh-zhoo”) figures, which are parametric plots that capture the visual nature of a harmonic system. Lissajous figures provide visual insight into the mathematical behavior of musical intervals in two dimensions and musical chords in three or more dimensions. For example, given two or more waveforms of fundamental frequencies: wavfreq1=sin (at + α), wavfreq2=sin(bt + β), etc., then we can easily plot the parametric curves using Matlab with lovely results.

In the theory of music, an octave is an interval with a pair of acoustic frequencies that range over a factor of two.

• On a piano (and most Western music) an octave is divided into twelve semitones with equal frequency ratios.
• Since twelve semitones comprise a factor of two, one semitone spans a factor that is 12th root of 2.
• The pitch we hear is the log of frequency, so successive pitches sound as if they are equally separated.
• σ (sigma) will be the basis for determining frequency intervals in our Matlab programs.
>> sigma = 2^(1/12)

% Here is code for plotting the 12 harmonic music intervals in Western music
% We take rational powers that approximate integral powers of sigma,
% which achieve more satisfying results
sigma = 2^(1/12);
powers = (0:12)';
equal = sigma .^ powers; % equal temperament
[num den] = rat(equal, .02);
figure;
for s = 1:12
t = linspace(0, 2 * den(s + 1) * pi, 500);
x = sin(t);
y = sin(num(s + 1)/den(s + 1) * t);
subplot(3, 4, s);
plot(x, y);
st = sprintf('%d/%d', num(s + 1), den(s + 1));
title(['\sigma^p : ' st]);
end


Here is a sample Matlab program based on usage of fractional powers of sigma for a sequence of 2-D plots of musical intervals. I leave the reader with the challenge to design a simple user interface to control the plot with respect to the movement to higher and lower frequencies.

%Matlab code to plot an animation of changing musical intervals
sigma=2^(1/12)
t = (0:0.1:100);
for a=0:.01:12
plot(sin(t),sin(sigma^a*t))
title(a)
if (mod(a,1)==0)
pause(1); else pause(.05); end
end



% Here is code for plotting musical chords based on 3-dimensional Lissajous figures
t = (0:0.1:360);
for a= 11:1/60:60
plot3(sin(t),sin((1+a/60)*t),sin(3/2*t))
title(a)
if (mod(a,1)==0)
pause(2); else pause(.05); end
end



Monday, October 24, 2011

Demystifying the PageRank and HITS Algorithms


Demystifying the PageRank and HITS Algorithms...
Or just enough linear algebra to master network-based ranking methods


There is a ton of information on the internet about how search engines work. One important aspect of of the final ranking in any given search is based on webpage ranking algorithms that run 'under the hood'. The hyperlink, network-based algorithms known as PageRank and HITS are the two most prominent examples of such methods. However, much of the information on these methods is either misleading or confusing, and really does require only a little bit of mathematics to understand well.  The main idea is that the rank of any page is dependent on the number of backlinks (or in-links) to that page, and the importance or quality of the pages that contain those backlinks. Unfortunately, most explanations of how this is precisely computed uses the language of linear algebra and "eigenvalues", which often obscures the relatively simply ideas underlying them. Here is an attempt to make these algorithms more accessible by boiling down the math to the essential details.

Let G be a directed graph. We think of the nodes of G as webpages and the directed arcs as hyperlinks. Let A(G)=A be the adjacency matrix where A[i,j] = 1 if (i,j) is an arc, is 0 otherwise. The ith row of A is the (characteristic) vector representing all the out-neighbors of the ith node, and the jth column of A is the vector representing the in-neighbors of the jth node. The transpose matrix A' has the roles reversed, where the ith row of A' is the vector representing all the in-neighbors of the ith node, and the jth column of A' is the vector representing the out-neighbors of the jth node.

Matrix multiplication can give simple algebraic representations of graph structures. For example, the square of the adjacency matrix A^2 has as its [i,j]th entry the number of 2-hop paths from ith node to jth node. And the product A'A has as its [i,j]th entry the number of nodes that are common in-neighbors to both the ith and jth node. Note how A'A is a symmetric matrix, likewise AA' is also symmetric. Symmetric matrices have the property that the [i,j]th entry matches the [j,i]th entry for all pairs i,j.


Stochastic Matrices


Let us place a probability distribution on the out-neighborhood of each node – that is, we give a positive weight (between 0 and 1) to each arc, with the property that the sum of weights out of each node is exactly 1. We call such a matrix a stochastic matrix. 



 


Figure 1. Stochastic matrix obtained from a digraph where a uniform distribution is used at every node.


Markov Chains and PageRank

Given a stochastic matrix P we consider each entry as a transition probability of a random walk, or equivalently, the transition probability matrix of the Markov chain. A stationary distribution of a Markov chain is a probability distribution d on the nodes, so that P'd =d, i.e., d is a fixed point under the action of the transition matrix. For such matrices we can apply the fundamental theorem of Markov chains, which says that, under certain conditions,  stationary distributions always exist and are unique.
PageRank associates this unique stationary distribution is with a ranking of the nodes of a web-graph.


The proof of the existence of the stationary distribution or fixed point,  relies on a result called the Perron-Frobenius Theorem for non-negative, irreducible matrices, which essentially states that any such Markov chains has a left eigenvector of P with eigenvalue 1. We can simplify matters significantly by considering the restriction to positive matrices, which indeed what PageRank does in practice.

The Perron-Frobenius Theorem for positive matrices:
Let A = [a(i,j)] be an n × n positive matrix: a(i,j) > 0 for 1 ≤ i, j ≤ n. Then there is a positive real number r, such that r is an eigenvalue of A and any other eigenvalue λ (possibly, complex) is strictly smaller than r in absolute value, |λ| < r. T



An Algorithm for PageRank

A simple consequence of the Perron-Frobenius Theorem for positive matrices gives us an algorithm for computing the PageRank (the unique stationary distribution) for graphs to which it applies. Namely, by simply powering up or iteratively updating a distribution vector, starting from an arbitrary initial state (usually taken as the uniform distribution). Each iteration of this algorithm takes time O(|V| + |E|), and will often converge very quickly.


Determinants and Eigenvalues of Matrices

A determinant is a function that associates a scalar value to a square matrix. The value of the determinant can tell you if the matrix has an inverse or not. A matrix with a nonzero determinant is called regular or an invertible matrix (and, we can calculate its inverse matrix). If the determinant is zero the matrix is called a singular matrix and it does not have an inverse.

Formally, a determinant is computed by a sum of products over all permutations of numbers 1 to n, and therefore has n! terms in the sum. Determinants over 2 by 2 matrices, that is where n = 2, have only two terms (a11 * a22) – (a12 * a21) and are simple to calculate by hand. For larger values n>2, the number of terms start to get out of hand. 

All regular matrices can be transformed into singular matrices by subtracting common value from the diagonal entries of the matrix. The problem of transforming a regular matrix into a singular matrix is referred to as the eigenvalue problem. The Eigenvalue Problem is determined by subtracting c*I from A and setting the determinant to 0, and then solving for c. Given a solution c to the eigenvalue problem we can find a vector (a class of vectors) X such that AX=cX. Any such X is called the associated eigenvector for eigenvalue c. 

One of the simplest methods for finding the largest magnitude eigenvalue and an associated eigenvector is called the Power Method. Given a matrix A and an initial vector b0 that is a linear combination (that is, a weighted sum) of eigenvectors, we can see that by repeatedly multiplying each vector bi by A, we are reinforcing (the direction) of the eigenvector with the largest magnitude eigenvalue (relative to the direction of the other eigenvectors in the sum). Hence, the power method is applicable in cases where the the following technical conditions hold:

1) A has an eigenvalue that is strictly greater in magnitude than its other eigenvalues.

2) The starting vector b0 has a nonzero component in the direction of an eigenvector associated with the dominant eigenvalue, i.e., b0 is not orthogonal to the eigenvector.


The Power Method for Principal Eigenvector



The power method algorithm starts with an initial vector b0, and is described by the following iteration to compute successive vectors:
for k = 0,1,2,3,...
  b(k+1) = A(bk) / || A(bk)||

Convergence is guaranteed when above conditions 1)  and 2) hold.

The HITS Algorithm for Ranking Webpages

The HITS algorithm is a conceptually simply link based ranking algorithm based on the power method, which posits two parameters for each webpage: an authority value a_i and a hub value h_i. Authority values are simply the sum of the in-neighbor hub values, and similarly the hub values are the sum of the out-neighbor authority values. So hubs and authority values are mutually dependent. In matrix form we have the following two matrix-vector equations:
a= A'h and h = Aa

Plugging back in for h and a leads to the following equations yielding an pair of eigenvector problems:

a= A'Aa and h = AA'h


a= A'Aa and h = AA'h

Looking at these equations we can see that we seek eigenvectors associated with eigenvalue 1 for each of the pair of matrices A'A and AA'. We cannot in general assume that such eigenvalue/eigenvector pairs exists, but we can find other eigenvectors associated with the largest eigenvalue using the normalized Power Method described above, so long as technical conditions are satisfied. To wit, as noted both A'A and AA' are positive, symmetric matrices. Such matrices have the property that all the eigenvalues are positive reals, and the associated eigenvectors form a basis, that is every vector is a linear combination of eigenvectors. Hence, we can be assured that the HITS algorithm will converge to the (normalized) sum of eigenvectors associated with the largest eigenvalue (for which the starting vectors a_0 and h_0 have non-zero component). We are in good shape if these vectors are real-valued, so that we can interpret the components as ranking values. The theory says that as long as the matrices in question are "irreducible" then we are in business.