# The Social Network Ranking is Wrong

**The Pith of Performance**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Call me old-fashioned, but I never saw the movie *The Social Network* until last year (at a private screening). In case you also missed it, it’s the Hollywood version of how Facebook.com came into being.

Quite apart from any artistic criticisms, I have a genuine psychological problem with movies like TSN. I keep getting caught up in technical inaccuracies and tend to lose the plot. So, it’s very hard for me to watch such movies as the director intended. It’s the same reason I can’t stand SciFi movies or books: I can’t get past the impossible. It turns out that TSN is generally fairly accurate regarding things like Linux, MySQL, PHP, and so forth, but there is a real clanger: the ranking algorithm used by Facemash—the Facebook precursor.

Mark Zuckerberg wants to rank Harvard women based on crowd-sourced scores. He recalls that his best friend (at the time), Eduardo Saverin, had previously mentioned a ranking formula but Zuck can’t remember how it goes. When Saverin shows up again, Zuck urgently asks him to reveal it. In typical Hollywood style (and perhaps to keep a math-phobic audience visually engaged), Saverin writes the following **ranking equations** on the dorm window for the desperate Zuckerberg. Where else would you write equations? \begin{align} Ea &= \dfrac{1}{1 + 10 (Rb-Ra)/400}, & Eb &= \dfrac{1}{1 + 10 (Ra-Rb)/400} \label{eqn:movie} \end{align} There’s just one slight problem: they’re **wrong**! I wasn’t sure at the time, but as Saverin was writing them, I was thinking to myself, “Why wouldn’t $10/400$ be simplified to $1/40$?” Even a Harvard student could figure that out. And, on continued mulling: “If woman ‘a’ and woman ‘b’ had a rank difference of $-40$, the fractions would blow up! How can you rank infinity?”

You see the kind of mental problems I have. As I continued to try and watch TSN, I decided that perhaps I had misread the equations. The scene goes by quite quickly when you’re not expecting it, and I didn’t want to ask the host to replay that section of the movie just for me. By the time TSN ended, there were some other suspect scenes^{*} and it was getting too late in the evening to review the entire movie.

The next day, however, I checked the web and it wasn’t hard to find references to TSN with the ranking algorithm scene, some of which thankfully included a video clip. To my surprise, nobody else seems to have spotted the error. Sure enough, the equations that Saverin writes are indeed those in \eqref{eqn:movie}. Moreover, I also found the original **movie script**, and on pages 15 and 16 the equations are incorrect there too—written exactly as they appear in \eqref{eqn:movie}. The guy who played Eduardo Saverin must be a good actor because he followed the script exactly.

So, what are the **correct equations**? It turns out the equations come from ranking chess players, which is probably how the real Eduardo Saverin knew about them. That’s how it’s portrayed in TSN. Anyway, Saverin didn’t *invent* them. The correct equations are: \begin{align} Ea &= \dfrac{1}{1 + 10^{ \big( \frac{Rb-Ra}{400} \big) }}, & Eb &= \dfrac{1}{1 + 10^{ \big( \frac{Ra-Rb}{400} \big) }} \label{eqn:chess} \end{align} Note the **exponential** form. This has the effect of giving the ranking equations a complementary sigmoidal shape such that when the score of woman ‘a’ is up, the score of woman ‘b’ is correspondingly down. This fits with the requirement (not mentioned in TSN) that $Ea + Eb = 1$: the relative scores have to add to 100%.

Furthermore, this is not just a simple typographical error due to a missing ^ (caret) exponentiation character in Excel or Word; the most likely applications used for the movie script. The 400 has to go *inside* the exponent of \eqref{eqn:chess}, which means that *more* brackets are needed than shown in \eqref{eqn:movie}. In other words, the movie equations are a bit of a mess, transcribed by someone (presumably the scriptwriter) who had no idea what he was writing. Nothing new, I suppose, but these days Hollywood is known to hire experts (like mathematicians) to verify movie concepts. Not in this case, apparently.

Finally, it also occurred to me that if I replace the $10$ in the chess equations by the number 2.71828 (otherwise denoted by the letter $e$), I get the Fermi-Dirac distribution^{†} over energy range $E$ at a given temperature $T$ (see above plots): \begin{align} Ea &= \dfrac{1}{1 + 10^{ \big( \frac{Rb-Ra}{400} \big) }}, & f(E) &= \dfrac{1}{1 + e^{ \big( \frac{E-\mu}{kT} \big) }} \label{eqn:elofd} \end{align} The Fermi-Dirac function, $f(E)$, is key to understanding how electrons “rank” *themselves* in a **semiconductor** circuit; a different kind of **network**, also made famous in the Silicon Valley.^{‡}

^{*} For example, the scene where the computer science lecturer asks the class an impromptu question. Everyone is stumped. Not too surprising since the question is so hopelessly ill-posed that nobody would be able to provide an answer. Undeterred by such details, the Zuckerberg character superciliously throws off the (“correct”) answer as he storms out of the room in a huff. Not only is the technical question ludicrous but, according to the real-life lecturer of that Harvard class, neither that nor any similar event ever occurred! ^{†} In a twist of irony while writing this blog post, I recalled that in another but not totally unrelated context, the Bose-Einstein distribution has also been applied to the Hollywood movie industry (PDF). ^{‡} Here is the R script for producing the above plots.

<br /># Compariosn b/w chess ranking equations from the movie <br /># "The Social Network" and the Fermi-Dirac distribution.<br /># Created by NJG on Monday, January 14, 2013<br /><br />op <- par(mfrow=c(1,2), pty="s")<br /># Normalized Chess Ranking profile<br />Ra <- 1<br />Rb <- seq(0,2,0.01)<br />plot(Rb, 1/(1+10^(((Rb/Ra)-1) * (Ra*1000/800))), type="l", ylim=c(0,1), xlab="Rb/Ra", ylab="Ea",col="red")<br />lines(Rb, 1/(1+10^(((Rb/Ra)-1) * (Ra*1000/400))),col="green")<br />lines(Rb, 1/(1+10^(((Rb/Ra)-1) * (Ra*1000/1))),col="blue")<br />title(main="Chess Ranking Dsn")<br /><br /># Fermi-Dirac distribution<br />E <- seq(0,2,0.01)<br />plot(E, 1/(1 + exp(1)^((E-1) * 2)), type="l", ylim=c(0,1), xlab="E", ylab="f(E)",col="red")<br />lines(E, 1/(1 + exp(1)^((E-1) * 10)),col="green")<br />lines(E, 1/(1 + exp(1)^((E-1) * 400)),col="blue")<br />title(main="Fermi-Dirac Dsn")<br />par(op)<br />

**leave a comment**for the author, please follow the link and comment on their blog:

**The Pith of Performance**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.