Understanding how Utah’s congress votes

Clustering of Utah Members of Congress by Vote

By using the data from each congress member’s vote, we can actually group together different representatives based on how they have voted. We do this by using an algorithm called K-Means. This is an algorithm that creates a center point between each point (each representative’s votes), and then prints them.


Learning from Video Game Sales

Over the past 20 years, so many video games have been released, and some of them have enjoyed a lot of success. As in any artistic medium, critics spend a great deal of time reviewing many of the releases each year. But the question is, are critics in tune with game popularity?

Take for example the popular series Call of Duty. Many of the most popular titles released in the franchise are highly reviewed by critics, but not always. Here’s what a scatter plot looks like if we try to get an idea of how well sales went:


It appears that, for this popular series, the correlation between sales and reviews is there, but very weak. But that’s just one series, what would happen if we take a look at many more games, would we see anything?


It seems like there might be a connection between scores, but we can’t be too sure just by taking a look at the image. So we need to get a number that can represent how closely the two are connected. That’s what a correlation coefficient can tell us. If we calculate that, we find that they are connected, but not too strongly. The correlation is .18 (the maximum correlation something can have is 1), meaning that higher scores are predictive of a successful game, but that there are other factors that seem at play too.

Note that I only included games that made more than $1 million. Some are so low that it makes it very difficult to visualize. If we take the correlation of sales and scores for all the games, the number actually goes up to .25.  Just like before, it tells us that scores play a role in how well a game does, but they aren’t everything.

What are other ways we can predict if a game is going to do well?

Let’s go back to the example of the Call of Duty series. Since 2000, at least one new game has been added to the series every year. It must mean that the popularity of the series leads the publisher to ask for more each year. And if we look at a graph, it looks like sales have indeed gone up almost every year.


When we look at the correlation we get .86, which means that sales are strongly related to what year the game was released. It appears that building a brand can really payoff in the gaming industry! But if that’s the case, we should look and see if there are other games with sequels that sell so well. Since programming a way to determine whether a game has sequels could be time consuming, I’m going to leave that question for now. I might come back to it later when I have time.

Does it matter what console a game is sold on? What console makes the most money? Graphing is a simple way to look at that question. If we graph the sums that each console has made, this is what we get:


But don’t assume right away that it’s a bad idea to make a game for the PS4! These are the total sales, we don’t know what a game on each system would normally make. If we instead graph the averages, we get a different picture:


If you take a look at the Playstation consoles, they almost always get the highest average sales of all the systems in their generation (excluding handheld devices, Nintendo has a corner in that market), with the exception of the generation the Nintendo Wii was released. So if you are going to release a game for just one console, shooting for a Playstation console is not a bad idea.

Bad news for PC gamers like me: it looks like PC game sales are pretty low compared to consoles. PC games usually have a longer shelf-life than games for other consoles, since older games can often still be played on newer computers. But even with that extra time, the PC performs much lower than other systems. If you’re wondering why PC ports these days seem like an afterthought, then, you can see why they’re a bad investment for game publishers. On the other hand, getting a game on PC distribution services like Steam is a lot easier than for Playstation, so that opens up the playing field for indie developers. Just don’t expect (if you are one) to make AAA game profits.

Thanks for reading! Let me know if you have any input! If you are interested in taking a look at how I analyzed the data for these visualizations, you can check out my code on Github. It also includes some extra exploratory analysis that I didn’t include here. If you’re interested more on this project, check out the main page.

Note: This blog post was inspired by an activity in the Data Learning Club. If you’re interested in becoming a data scientist, I would recommend joining in with the club and listening to the companion podcast Becoming a Data Scientist.

Those Angry Liberals: What Conservatives Tell Me I Believe

While I try to avoid associating myself too strongly with political ideology, I do realize that I tend to lean left on a lot of issues. So I end up being exposed to liberal viewpoints. But I try to see what different viewpoints there are and give them a chance.

Conservatives know everything about how angry liberals are. Here are some things that just drive liberals crazy :

You being heterosexual. That post you re-shared from your friend about straight pride just gets us soooo angry because we hate straight people. Anything that isn’t gay is not okay. Don’t look too hard at the comments, if you do, you might notice that there are not any liberals upset about your sexual orientation. They might grab the bait to let you know that you’re trivializing a very difficult step homosexuals make by coming out of the closet, but don’t pay too much attention or you might realize that they don’t care that you’re straight (hey, they might even be straight too!). Coming out as straight has had such dire consequences you know, like kids being kicked out of their homes, being abused, bullied, and hurt by school mates (I think that’s what happens, right?).

Marriage. We may be trying to make the marriage institution more inclusive to families, but it’s just a ploy to destroy your marriage. We don’t care about the challenges gay couples have gone through because their relationships haven’t been recognized by the state, we really are just working towards forcing everyone to get gay married. It’s for population control. We also want to make sure your kids have to watch MTV everyday in school right after they twerk to the Star-Spangled Dubstep.

Freedom of Speech. We don’t like people criticizing us, so we’re going to use capitalism to force you to stop saying horrible things about gays. See, when we call you out for saying something that isn’t true or for your racist, sexist and homophobic statements that’s called suppressing your freedom of speech, not our free expression. Remember, the freedom of speech makes it so you can say whatever you want, whenever you want, to whoever you want without worrying about ANY social consequences.

Your guns. There’s that one hated British political pundit that was on CNN that said he doesn’t like guns, therefore all liberals feel that way. We just say that we want to do background checks for gun transfers to trick you into thinking we like guns. We don’t ever go shooting or anything like that. We’re only pretending to be nuanced so you can catch the bait.

Christians. We hate Christians. Ignore all the liberal Christians: they don’t represent us. We’re all God-hating, jihadists who want to eat Christian babies for breakfast and destroy your religion. We may say we’re for separation of church and state but we’re secretly finding ways to establish a Satanic cult as the state religion. And then force all of your children to pledge their allegiance to the Flying Spaghetti Monster each day at school. We may say we don’t like the way you want to force kids to pray in school and base policies on your beliefs while trampling on those of others, really we want to send all Christians to a camp where they must sing songs praising Karl Marx.

Work. We’re trying to turn our country into a wasteland of lazy couch potatoes by giving everybody free handouts. We don’t care about the evidence that the majority of food stamp recipients get off them within a year, we just want to sit back and relax while conservatives go to work. There isn’t a single liberal that works hard. Especially not those liberal professors that say they work hard to get grants, do research and raise up a new generation of moral relativists.

Patriotism. We think this country is just the worst. You won’t see us drinking beers wearing cut-off shorts and an American flag tank top while listening to “Born in the USA” on the Fourth of July. No, we hide in our rooms while staring longingly into the handsome eyes of our Stalin poster. We don’t try to make America a better place. We don’t try to improve health care. We don’t try to combat systematic racism. We don’t try to make the country a place where immigrants can live the American Dream. We just want to see this country crash and burn and roast organic, GMO-free marshmallows on the flames of a destroyed nation.

I think this is enough for you to see how nice and loving us liberals are. Keep reading this blog (that usually does not mention politics), and maybe one day you can be like us anti-American liberals. In the end though, you won’t have to choose it, cause we’re going to take away your rights to turn this country into the utopia the Soviet Union never was.

[In case you didn’t notice, this post is satirical. ]

P.S. The rest of my posts are NOT satirical. At least for now.

Musings on Caitlyn: Why Transgender People Aren’t Crazy

If you’re sick of hearing about Caitlyn (or Bruce) Jenning, there’s nothing to see here. Move on. Find some cute kitten videos on Youtube. You won’t regret it. In fact, here’s some links to some amazing animal videos:

But for those who care to listen to my blabberings about the topic, here it is:

I don’t know much about Caitlyn Jenner (evidence: I misspelled her name in the first version of the post). I just found out about her yesterday or the day before. So I can’t say anything about her character, about how she treats her family and friends. I don’t know her motives in being so public about her gender transition. She might be a hero – letting those who feel utterly alone in their struggle to understand their gender identity know there is hope for them – she might be a sensation seeking narcissist – or maybe she’s a normal person that just happened to be swept up in a media hype. I don’t know.

Here are some things, however, that I think should be considered when we talk about someone that is transgender.

First, it is unlikely that anyone takes the decision lightly, and it is difficult to receive a treatment on a whim. In the US, the condition of gender dysphoria must be well documented for a patient to receive a hormone therapy, and for a surgical treatment the patient is generally required to live as the gender a year before. And if the patient has significant mental health issues, they must be reasonably controlled. It would be difficult and silly to make the transition just because you want to check out girls in the bathroom or changing rooms (besides, anyone heard of Google?). Those who believe it is some perverted plan to have free access to women’s bathrooms have not considered what the transition would mean in the slightest – the person would have to live forever with changed genitalia, the bathroom still wouldn’t give a peeping Tom too many opportunities to stare (and there would be the additional inconvenience of lines at big events!), and sexual access to females would be severely limited.

In addition, there is little reason to believe that gender incongruence is something a person chooses to put upon themselves. There are plenty of developmental and biological ways that a person’s brain could possess the traits of a gender differing from the sex assigned them at birth. A sudden surge in estrogen during a sensitive period while in womb could cause an XY fetus to develop a ‘female’ brain, or a temporary lack of testosterone could prevent the emergence of a ‘male’ brain. In fact, by varying the hormone exposure in the womb, researchers were able to ‘create’ male rats that behaved as females. In this instance, the mammals literally had gender incongruent brains. Brain scans on transgenders have confirmed that sexually dimorphic areas (parts of the brain that are different between males and females) are much closer to the gender they identify with than their birth sex.

Most important, I feel, is that their feeling of being in the wrong body is very real. The kind of mental distress they feel at the difference between what they feel their gender is and their biological sex can be severe. There are reports of individuals before their transition feeling utter repulsion at the body they possess. With that dissonance affecting all aspects of their lives, these people need treatment. And the treatment is not to suck it up and pretend all is well. That rarely bodes well for those afflicted with this challenge. Really there are only two potential paths of treatment – modify how the person views their gender (in other words, mold their cognition into their biological sex) or change their sex. I know of no success with the former given the complexity of brain and cognition, and with modern medicine the latter is in the reach of many transgender citizens throughout the industrialized world. So if the dissonance between a person’s sex and gender is causing them distress, I find no reason why they shouldn’t consider the treatment available today.


A year of psychological evaluations before one can receive treatments to change sex – and the psychiatrist has to approve the treatment after giving a number of tests to the patient.

This was modified because hormone and surgical treatments were conflated as one. The sentence now appears:

The condition of gender dysphoria must be well documented for a patient to receive a hormone therapy, and for a surgical treatment the patient is generally required to live as the gender a year before.

Citations were added as well.

Real Life Superheroes

Yesterday I saw a preview for yet another superhero-like movie, complete with some very implausible and impossible superpowers. I’ll talk more about that movie some other time, but I want to talk about a thought I had.

If we had superheroes here on earth, what would they be like?


Face it, at one time or another we’ve all wanted to be some sort of superhero. While I don’t think someone is going to start shooting out flames from their hands, turn invisible, or begin to fly, there are some people with special abilities that, given the right back story and circumstances, could turn them into real life superhero.

So here are a few real special abilities that real people have (or have had) and what they might be like as a superhero:

1. Remember that scene in Spiderman when Peter Parker discovers that he can suddenly see everything in slow motion?

Wrong photo, I know, but it's the best I could find.

Wrong photo, I know, but it’s the best I could find. Also, remember Tobey Macguire’s bug eyes?

According to Oliver Sacks in a podcast of Radiolab, there is totally a girl that processes everything super fast. So when people play catch with her and tell her to wait a few seconds before throwing the ball, she catches it and says she counts to ten before throwing, and then throws it to someone else so fast there doesn’t seem to be a pause. Imagine what kind of things she could do if she began donning stretchy pants and fighting crime. I don’t know if she’s this quick, but what if she could dodge bullets? She could be the ultimate crime fighting machine!

2. Unstoppable long distance running:

In just about every superhero movie we see really long fight scenes, yet somehow most of the heroes don’t seem to get tired. Imagine being able to fight off the bad guys without getting tired!


According to (once again) Radiolab, Diane Van Deren, is a runner that hardly gets tired. And she has a slightly superhero-like back story. Since being a kid, she had suffered from epilepsy. It began to get very severe, so doctors decided she needed brain surgery. After the surgery, she realized that she could no longer keep track of or perceive the passage of time. Which worked really well for her interest in long distance running. She began competing in the super marathons, which can be up to 100 miles long. Since she couldn’t perceive time passing, she doesn’t realize when she’s supposed to be tired, making it easy for her to keep going even after a lot of running. She has won many of these races (even though she gets lost sometimes) because she just doesn’t stop.

3. This guy:

Anybody want a peanut?

Anybody want a peanut?

Come on, imagine trying to fight someone as big as this guy! We all know what happened when Wesley tried, even with his super strength… Anyways, if you’re going to have a team of superheroes, you gotta have the giant super-strong guy somewhere, and who better than Fezzik?

4. The bionic kind of superhero is a definite possibility. While I don’t know if we have crazy technologies that make it so they can jump super heights yet, could you imagine fighting someone with a metal leg? Take this guy for an example: he has rode a bike across the US, and he made his own prosthetic legs to do it. Genius plus mad skills? There’s one potential superhero for you! Plus, he’s a marine veteran, so he probably already has some superhero like skills. Don’t mess around with him.

Don't want to bike to work because a few miles are too far? Try the US!

Don’t want to bike to work because a few miles are too far? Try the US!

5. That rich kid teamed with a genius engineer.

Come on, we all know Batman is the best superhero! There totally could be some rich playboy with a complex enough back story to become a crime fighter at night. Given all the economic inequality in the US, we could totally argue that Ra’s al Guhl and the Shadow League is off trying to destroy the economy and country. Who knows what superhero will come? As for me, my bets on the Gates family.

6. You! Given the right back story, who knows what you have the potential to do? Are you a biological engineer that will create synthetic fibers with the strength of spider webs? Are you a rich genius? Or do you just like doing good things? Who knows what could happen!


Now, we haven’t had any sightings of masked superheroes running around the street at night saving people, but it’s fun to think about. Let us know in the comments section what other real super powers there might be!



Something Delicious (A Mostly Vegan Chocolate Shake)

My wife has been trying to go mostly vegan these last few weeks, so I’ve been exploring ways to make food awesome still without using even dairy products. Which seems like it could be hard. But the good thing is that my stomach has been a bit happier with me lately, and I have  been somewhat successful. So I thought I would share with you one of my successes!

Also, so far I haven’t received any amazing vegan powers. I’m still working on getting rid of the curds and whey in my brain.

Mostly Vegan Chocolate Coconut Awesomeness Shake

Here are the ingredients:

1 Cup Ice

2 Frozen Bananas

1 Cup Almond Milk

1 Cup Coconut Milk

1/4 Cup Cocoa Powder

1/4 Cup Honey – This is what makes it mostly vegan, I’ve heard some vegan purists say honey doesn’t count. So if you are a purist try some other magical sweetener that I don’t know about. I won’t judge you.

1. Put it all in a blender.

2. Blend.

3. Enjoy, and appreciate the fact that it’s an amazing shake that won’t give you a stomach ache!

There Will Always Be Problems

While running participants in two different studies using EEG, I’ve noticed something that seems consistent: nearly every time we run the experiment we run into a new problem. That shouldn’t come as a surprise: when you’re running a wireless device through the computer while running two or three different resource draining programs you should expect trouble. But I still am surprised ever day by all the problems that come up. One day there’s an electrode that’s causing problems, another the computer isn’t picking up the EEG, another the computer completely crashes, and all the other days E Prime (the software that runs the experimental designs) won’t start up right.

Although it hasn’t been too long, I’ve learned to expect something to go wrong, even if it is slight. This helps me keep from getting frustrated, prepares me to deal with problems as they come, and sometimes makes it possible for me to be pleasantly surprised.

This lesson in the lab has reinforced something I’ve already learned: when I expect to run into problems I’m much more able to cope. On the other hand, when I only expect the best I usually end up with disappointment and frustration. In high school, for example, after a long day on an empty stomach I was ready to get home and eat the leftovers of some delicious meal. But when I returned I found that someone else had finished it off, and that all the food in the kitchen required some time to prepare. I was pretty upset! But that moment wasn’t unique; it was just like any other time I’ve been disappointed: I was bothered only because I had expected the best.

I’ve realized that expecting things to go wrong in the right ways can prevent or reduce a great deal of distress in just about everything we do. I don’t mean we should be pessimistic, but knowing that things won’t go as planned is liberating and calming. This mindset prevents me from freezing in panic when the problems come up and allows me to find solutions. Some might think I’m a pessimist, but I’m not because I do have high hopes! The difference between acknowledging that things can go wrong and being pessimistic is that pessimism lacks hope. You can still hope for the best even when you are ready for the worst. Expecting problems makes it easier to deal with them when they come because we’ve already mentally prepared ourselves in a way.

Here’s a graphical representation of me when problems come and I’m only expecting the best:bush-dumb-look-scratching-head

Here’s what I look like when I’m prepared for the worst:DarkKnightRisesPoster1

Maybe that’s why all the self-help books like “The Secret” bother me immensely – because when things don’t work out the blame goes to the person who didn’t think positively enough. I’ve found far more happiness and success being ready for failure and problems than when I’ve tried to just “think positively.” I believe that extreme optimism is a reflection of our quick fix, easy answer culture. Really many suggestions from well meaning people to think more positively can complicate our lives by hiding reality. Reality is often unpredictable, sometimes counter-intuitive, and requires being in the moment – even when there are unexpected problems.