The Talking Stick Blog

News, Updates, Program Recaps, and Homeschooling Information

Spotify and Random Number Generators

(October 12, 2017) “Everybody get a partner. Take a piece of paper. Take a pencil. Number your paper 1-30. You’re all going to flip a coin 30 times. In each partnership, decide which person will flip a real coin and which person will flip an imaginary coin.”

That got their attention!

I needed to harness their attention because many of the students had come in very excited to see each other. I didn’t want to raise my voice, shush them, or otherwise dampen their spirits. Instead I wanted to quickly channel that enthusiasm into mathematical pursuits. So I ditched my planned discussion of the role of algorithms in computer programming, and instead delved right into something hands-on and interactive, something I had planned for a little later in the session.

After the students flipped their real or imaginary coins 30 times and recorded H or T next to each number on their papers, I asked them to compare lists of outcomes. “Which list appears to be more random, the real coin tosses or the imaginary coin tosses?”

WHAT DOES RANDOM MEAN?

Two groups concluded that the imaginary list was definitely more random. The other two groups agreed that while the imaginary list “looked” more random, the real list was actually more random.  This led to a heated debate about what random means, whether streaks can occur at random, whether the outcome of one event affects the outcome of the next, and more. Some of the students had studied probability and some had not, but everyone had something to say. Fortunately, I had to say very little. I did tell them of the gamblers fallacy, and from this discussion they were able to define randomness (not an easy task!).

IS SPOTIFY RANDOM?

I asked their opinions on whether Spotify shuffle is random. Another debate, even more heated. I had spent some time before class today perusing Spotify message boards on just this topic. I shared with the class complaints people had posted about getting too many songs in a row from the same genre. “Yeah, it’s really not random!” said a few students. But the students who knew some probability insisted that this can happen on random lists. Finally, I showed them some graphics about random distributions and Spotify. Finally everyone agreed that the human brain wants things to be more evenly distributed to actually feel random. The coin toss activity, the graphics about random distributions, and the info about the Spotify playlists all come from the same article in the Daily Mail. (I love this article!) Read it for more info about this topic, or better yet, for those of you with children in this class, ask them! They now know for sure whether Spotify is random.

ARE THERE DEGREES OF RANDOMNESS?

We then discussed Random Number Generators (RNGs) – what they are, their purpose, and true RNGs vs. pseudo RNGS. We played with a well-known example of a pseudo-RNG, the Linear Congruential Generator (LCG), which uses an algebraic sequence and modular arithmetic. We talked about remainders, which students often think they’re done with after third grade. “I like remainders better than fractions or decimals,” commented one of the more experienced students. We agreed that when you have a cyclical relationship, remainders might help you with a more intuitive understanding.

“Everything I just told you about RNGs I learned from my favorite youtuber,” I told the class.

“YOU have a favorite youtuber?!” said some, quite surprised.

“Definitely. Eddie Woo.” I encouraged them that any time they want more insight about a high-school math topic to go onto youtube and type in the math topic along with “Eddie Woo” to get a clear and interesting video. They were impressed that he has 70,000 subscribers. “Not bad for a mathematician,” they agreed.

We spent a lot of time on RNGs, but I’m not going into detail here because you can find all the content in Eddie Woo’s videos. One thing that came up in our class that didn’t in the video is curiosity about the precise mechanism for converting space noise to a list of random numbers. I didn’t know precisely how it’s done, but encouraged students to look it up themselves.

The example of the LCG that we did today generates a list with an obvious repeating pattern. Eddie Woo’s second video on this topic shows some graphics of what the LCG produces when you vary the seed number. I would have loved to show this to our group but didn’t have the technology to easily share it. I’d encourage everyone in the group to look at this video, starting at time 7:24, to get a better idea of the kinds of lists the LCG can produce.