Sunday, 16 December 2012

My experience of G+ as an academic

So Patrick Honner wrote a blog post about twitter for Math teachers. I thought I'd try and do something similar for G+.

DISCLAIMER: I don't know what I'm talking about. I'm in no way a social media expert and/or claim to have any better knowledge on this subject then anyone else. This post will most probably just turn in to a story about how I've used G+ over the past 18 months or so.


My General Philosophy

I've been on G+ for a while now and I'm a really big fan. I joined twitter and got an invite for G+ from an old pal about a month later. As I didn't have any attachement to twitter at that moment I didn't really have a reason to invest in it. I believe that G+ is by far the best designed social platform out there and I was an immediate fan. I thought I'd fully move over to G+ (once I figured out how to get all my photos off facebook I actually quit that). I wrote a blog post about this a while back.

My main rule from the start with G+ was (and pretty much still is apart from one exception that I'll get to in a bit): only post publicly about stuff linked to my "professional life" ~ so "science-y" stuff. I stick to this not because I don't want to share pictures of my holidays with the world but mainly because I think no one would care and I don't want to bore anyone. Having said that, I know a lot of people who share non "science-y" stuff publicly and I certainly enjoy reading it, for example Dana Ernst (a mathematician) often posts about his trail running activities which I always enjoy reading.

I know some people actually do the opposite and use circles to "direct" information. For example they have a math circle and post mathematical content to that circle. I personally don't feel that is the best way to do things as it stops people you haven't circled from finding your posts. 

I use circles for personal things (ie stuff I don't think the world cares about ~ with some friends we communicate via G+ instead of text messages as a bunch of us can follow a single conversation) and also to filter how I read information. For example I have a math circle, a programming circle and a news circle. During the day, depending on my mood I'll read from one of those circles.

That's the very basics of how I use G+ on a day to day basis. 

Some Anecdotes

I really enjoy G+ and have had some great interactions (by all means skip this section as it's just a couple of personal experiences):

- A recent conversation about the teaching of Game theory on one of John Baez's post is a great example of how G+ allows for sharing of knowledge and interaction. I "met" quite a few people on that post and got quite a few ideas for teaching.

- I've learnt a lot about R from Josh Wiley who even took a look at some teaching materials I was putting together. I'm not too sure how Josh and I met (ie on what post) but I guess it was following a series of conversations that I felt comfortable enough to ask him for a hand.

- I've had some students points out typos in my notes :)

- At the very beginning of my time on G+ I spent a while looking for mathematicians and Operational Researchers. One of the early people that I interacted with was Bo Jensen. Paul Harper and myself would chat for ages with Bo about how to use circles (I think we still don't agree :) ). We had a 1 year anniversary hangout:


All of the above are just some small examples of some cool interactions I've had on G+. One of the best things I've done that had some connection to G+ was when I posted about it during the long run my fiancĂ©e and I did (160 km over 5 days). This was from Cardiff to Gregynog (where a mathematics colloquium is held every year). This slightly broke with my above "rule" about just posting publicly about "science-y" stuff. Having said that it was a very special experience and I actually posted publicly about it the whole way using the hashtag (oh yeah they work on G+ as well): #jog2nog. On the second day I proposed to Zoe and it was kind of fun to share it.

How I do things

The main point for me about G+ is that you can make it as personal as you want. There is no "right way" to use G+. I've often discussed this on G+ when some people have stated that people "do things the wrong way". I think that's what's great about it, there is no right or wrong way to use it.

Having said that this is how I do things:
  • Engage on other people's posts. I think that I enjoy discussions on other people's post far more than on mine. So I often spend time just reading through posts chatting and meeting new people.
  • Engage with people on your posts. I'm always flattered when people take the time to post a comment on one of my posts so I always try to enter in to a conversation if there's scope for one. 
  • Don't circle everybody. I love the asymmetry of G+. This allows for the possibility that some people might be interested in what I say whilst I might not care for what they say (and obviously vice versa - there are quite a few people I've circled who haven't circled me back and I'm certainly not offended by that). I do my best to take a look at people who engage with me and often circle people who post stuff that interests me.
  • Tag wisely. There's a lot going on on G+ (people who call it a ghost town make me giggle but I'll get back to that). So it's tricky to see everything so I often tag people in to conversations if I feel that they might have something to add or might like to listen in. Similarly I always appreciate being tagged in to a conversation that I might be interested in.
  • Link to G+ stuff on other sites. Photos are awesome on G+ and a public post can be seen by anyone (whether or not they're on G+) so I often grab the link to a post (by clicking on the date stamp) and share that (that's in fact the only way I currently use twitter).
  • Have buffer circles. When large circles get shared I often add the whole circle but put it in a particular circle (eg "Science [to edit]" as opposed to my "Science" circle). I put the noise filter up quite high on that circle (see pic) and slowly move people I'm interested in over to my main "Science" circle.
  • NEVER "Also send email to ...". You can post to a particular circle and choose to notify everyone in that circle (see pic). I only ever tag particular people if I want them to seethe post but I never spam an entire circle. I don't recommend doing it as it's an easy way to make people mad...

Find stuff

People who call G+ a ghost town are like people who walk in to a busy bar with their eyes closed, walk out and say that no one was in there. Search for stuff you like (for example "math" and/or "science") and just meet people. If you don't want to meet people then I guess G+ also works, just sit by yourself and don't speak to anybody (I don't think that would be that much fun though).

If you want science take a look at the following:

- Fraser Cain's handpicked  science circle.
- The Science on Google+ Public Database: a bunch of circles on science.
- A small circle of Operational Researchers who post publicly. I put that together while ago so I really should update it.

Something brand new has appeared on G+ in the last couple of days: Communities. I'm still unsure about them as I'm a bit worried that they're compartmentalising information but just search for a community and you'll find people in there to meet :)

Some final thoughts

The one word I always think about when describing G+ to people is "learn". I have learnt so much from G+ (cool programming things, teaching methodologies, general mathematics etc). I am very grateful.

I never really got going with twitter and so I'm sure I'm "not using it right" but I just don't see how it can offer the same level of engagement as G+ does. A while back someone tweeted "at" me (I'm not even sure if I'm saying it right) and I wanted to answer (they complemented me and I wanted to say thanks). After 10 seconds I gave up as I wasn't sure how to get it all down in 140 characters and also I didn't want to confuse my followers on twitter. So I simply went over to G+ and sent them a limited message (i.e. posting to just them). We ended up having a long conversation about G+ and twitter. I don't believe that that would have happened on twitter but again, perhaps I wasn't "using it right".


I've not really mentioned hangouts. They're awesome. Use them.

Tuesday, 27 November 2012

Importing and Exporting data from and to csv files in python

When I first started using Sage one of the challenges was figuring out how to handle data outside of Sage. I made the terrible mistake of trying to learn Sage without knowing any Python. I've subsequently learnt Python (a language I absolutely love) and thought I'd do a short screencast showing how to manipulate csv files with Python.

Here's the screencast:


I thought I'd put the code I wrote up here as well:

import csv

out=open("data.csv","rb")
data=csv.reader(out)
data=[[row[0],eval(row[1]),eval(row[2])] for row in data]
out.close()

new_data=[[row[0],row[1]+row[2]] for row in data]

out=open("new_data.csv","wb")
output=csv.writer(out)

for row in new_data:
    output.writerow(row)

out.close()

Here's a quick explanation (basically repeating what is in the screencast)

The first line imports the csv module:

import csv

The next few lines open a file for reading (denoted by "rb") and use the csv reader method to import the data (the "eval" function is used to handle the fact that all the data is imported as a string).

out=open("data.csv","rb")
data=csv.reader(out)
data=[[row[0],eval(row[1]),eval(row[2])] for row in data]
out.close()

The next line simply creates a new dataset:

new_data=[[row[0],row[1]+row[2]] for row in data]

We then open/create a file called "new_data" for writing (denoted by "wb") and use the csv writer method to export each row of data:

out=open("new_data.csv","wb")
output=csv.writer(out)

for row in new_data:
    output.writerow(row)

out.close()

Saturday, 17 November 2012

Blog/YouTube Channel

I don't post to my blog very often yet I have started making a few more videos on my YouTube channel in one of three categories I guess:

- "Tech" (for want of a better name) how to's (or more exactly how I've figure out how to do stuff which might not be the best way...)
- "Education" (for want of a better name) stuff
- Research presentations

I've decided that I'll also throw those videos on here when I put them together (not too sure why, perhaps the best reason is "why not?"). To get started here are 3 past videos:

- Using GitHub to host a website:



- Simulating a Queue: Basic Discrete Event Simulation



- A game theoretical approach to the EMV ED interface



Tuesday, 23 October 2012

Playing games with MSc students

This is the fourth post in a series of posts  (see previous posts herehere and here).

I teach the first 4 weeks of the OR Methods module for our MSc in OR and Stats at Cardiff. One of the subjects I teach is game theory and this year I decided to introduce the subject through the use of the same games I've used in outreach events.

We had 31 participants. The first game we played was the 2/3rds of the average game. Here is the first set of guesses (before we discussed rationality and in essence solve the game together).
You can see that the guesses are pretty distributed across the range from 15 to 82. Three students did seem to notice that something was happening around 2/3rds of 100. The winning guess was 26, which is the highest winning first guess I've had so far.

After this we all went through the fact that 0 is the dominating strategy in this game (through iterated elimination of other all other strategies). Once this was rationalised we played again, here's the second set of guesses:
A few weird things happened, for example someone actually guessed 100 (there was no one guessing a 100 before). I suppose this shows some confusion or perhaps someone was just trying to tell me that they thought this was boring (despite the fact that I used a box of chocolats as a participation bribe... :) ). Otherwise the results are as one would expect and the guesses seem to be clustering a bit towards 0. The winning guess was 10 this time around (3 students had to share the chocolats) which is actually a tie for the highest winning second guess I've had so far.

Here's a quick summary of the 4 games I've played so far:
  • School kids (13 participants) - First Guess: 17 Second Guess: 2
  • Postgraduate students (80 participants) - First Guess: 18 Second Guess: 10
  • OR 54 Delegates (10 participants) - First Guess: 23 Second Guess: 3
  • MSc 2012 Cohort (31 participants) - First Guess: 26 Second Guess: 10

After this we put the guesses up for everyone to see and discussed what we expect to happen if we played again (and again). I thought this went well and I've had some of the students say they enjoyed it. I certainly enjoy teaching game theory as it's very "easy" to make come alive. After the 2/3rds of the average game we played a prisoner's dilemma tournament but I won't go in to that here. Here are a few photos showing the students discussing strategies and (hopefully) having fun.

Monday, 1 October 2012

Playing games at OR 54

The 54th conference of the Operational Research Society took place in Edinburgh from the 4th till the 6th of September.

Louise Orpin (Education officer of the OR society: http://learnaboutor.com/) was running a stream on education and thought that her and I could give the same talk we gave at SCOR (see previous blog post here) and I've given many times with Professor Paul Harper during high school outreach events (see previous blog post here). This talk is actually designed for school children. It aims to get kids to understand basic ideas of game theory by playing some games.

When asked to give this talk at SCOR I was worried that the audience (PhD students) would be a bit too "mature" for the talk and think it a bit of a waste of their time. The SCOR talk was a great success though and everyone had fun. When it came to giving the talk at OR54 I was also a bit worried as the audience was even more "mature". All these worries were unfounded as it seems that people just like to have fun and play games. It went well. Here are some of the results.

We did not have a huge audience (10) but still had enough to play the games.

The first game we played is the 2/3rds of the average game. Here's the first set of guesses (before discussing rational behaviour):

The guesses were relatively spread out, 2 groups of participants noted that 66 was 2/3 of 100 and also that 43 was 2/3 of 66 but no 1 guessed lower than 5. The winning guess was 23. After explaining the fact that 0 is a dominating strategy we had the participants play again. Here are the guesses second time around:
As you can see 0 was not uniformly picked but the maximum guess was this time 29 and 7 people guessed 3 or lower. The winning guess was this time: 3.

I've run this with 3 types of audiences now and the winning guess on each occasion were (links are to corresponding blog posts):



We had fun with this and discussed how such a game was a great way to get basic ideas of rationality and dominance across. 


We then proceeded to play a prisoner's dilemma tournament. We split in to 4 teams and the winning team would be the team with the least total score (I've blogged details about this before see here). It was good fun (always) and there was even a coalition that formed to stop the team, that had my undergraduate intern Jason Young, in it from winning. Here are some photos (thanks to Ian Mitchell for the first 2!) from that part of the day:

The cool venue:

Louise starting us out:


Louise and I with the "C" and "D"s used to cooperate or defect...


The scores (if you look carefully you should be able to notice the coalition - Jason chose the name for team D just to make me twitch...):


The above is just 1 example of an outreach event that works really well in schools (and also with more "mature" participants). If you do want more examples please do take a look at http://learnaboutor.com/. I'm writing this the day before teaching game theory to a new cohort of Cardiff MSc students, I'll be playing the same games with them so will probably post about it again at some point. 

(If you'd like more information on the Conference itself take a look at the #OR54 hashtag on G+).


Sunday, 16 September 2012

GUEST POST: A Summer Research Internship

During the early part of 2012 I applied for some funds to carry out research on game theoretical behaviour in hierarchical queueing systems. I successfully obtained money from the LANCS initiative (http://www.lancs-initiative.ac.uk/) to hire an undergraduate student to do a 10 week internship. The original goal of the project was to build a simulation model that would be used to aid the research project.

After interviewing half a dozen students I appointed Jason Young. Jason was an absolute pleasure to work with and worked extremely hard. Consequently a lot more was done through this project, Jason and I stil laugh about the fact that originally the plan was "just build a simulation model". As soon as I find some time I'll be writing it up for publication. 

At the end of the project I asked Jason to write up a blog post describing the internship from his point of view. First of all, I thought this might be interesting and second of all, I'll encourage future students to read Jason's thoughts. Here it is:


------------ 

Hello my name is Jason Young and I’ve been working this summer as a research intern. Over the summer I was tasked to build a simulation model of a queuing problem in python, and you can see the results of the project at the end of this post. 

It’s been an interesting experience, and an invaluable insight into the world of mathematical research, and into a working environment. To anyone thinking about or preparing for an internship, this will be the most valuable thing that you take away from the position. It’s a great opportunity to learn and build contacts in your chosen profession, especially if you do well. This is a crucial moment in any undergrads career, and a lot of future employers will look at your experience as a guide to how active you’ve been during your degree, and summer internships are a great way of gaining experience without taking a full year out.

When I first started this project, my attitude was very much that I needed to succeed. My supervisor used to say “Impress or Disappoint”, which is an accurate statement of how the project will go. If you don’t put 100% in, and do an okay job, it’ll make you forgettable  overall. The only way to make a lasting impression is to put as much effort in as possible. It helps in this respect to enjoy your project.

In the week leading up to the internship I did some prep work, learning the basics of python, which was pretty valuable toward the start of the placement. This is also the point where I began to enjoy the challenge of research. As an undergrad with little to no knowledge of how research was carried out, I was quite apprehensive of the whole thing. Once I got started however, I saw that It was something I was very much going to enjoy. The main idea behind research is why. After finishing the model, we began to investigate the problem and I don’t think there was a single occasion that there was a result that we didn’t understand, mainly because after each conclusion had been reached we thought about it. I think if you’re on the fence about a research career this is what you should consider. Personally this is the part I enjoyed most, gaining insights into this mathematical problem, and testing the theory from every angle.

After getting through a significant part of the project, I was told that I’d be able to present my work at a conference. This was a huge honour (I wasn’t told till after, but I was the only undergraduate there) but easily the scariest part of the project. People who researched for years and years would be sitting and watching me talk about my research, which had all of 9 weeks behind it. As you can imagine the weeks leading up to it were a rather stressful affair. I spent an entire week getting the presentation ready, to me and my supervisor’s satisfaction and practicing it in front of some post grad students, who were very kind to stay late and watch, giving some really good feedback. After all this preparation, I was still quite nervous about the whole affair, but once we got to the conference itself, I relaxed quite a bit. Most of the people there were entirely there to learn and question, and didn’t mind me joining in any discussion about research interests. This and the fact that the presentation went really well (One of the questions asked gave us an entirely new train of thought) made it a great experience.

At times it’s been stressful, especially when the work piled up, but with enough persistence there was always enough time and my supervisor was extremely helpful and really pushed me to do the best I could. Overall I’ve loved the work that I’ve done this summer, and really proud of the result.

------------

The various outputs of the project can be found here:


  • With a few weeks to go Jason did a short screen cast showing the negative effect selfish behaviour can have in queueing systems:



  • Jason presented his work at OR54 (the annual meeting of the UK Operational Research society). Here's a screencast of the talk he gave (the sound quality is terrible but there's a blooper at the end):
  • The above slides can be found here.
  • A version of the program used can be found here (I'm still hoping that Jason and/or I will find time to clean this up a bit).
  • Here are a few pics from the project:
Jason had a bunch of computers in a lab running code. This one was Guinevere.
Arthur.

Excalibur. 
Lancelot.
Gaius.
Morgana.
Practicing the talk on the flight to Edinburgh.
This is where we screencast the talk.
Here's a picture of Jason presenting at OR54.

Saturday, 4 August 2012

Road cycling and an explanation for cooperation.

I'm a huge Tour de France fan. I would probably follow more road cycling if I could but I just concentrate on the Tour de France which turns up once a year. First of all it is a ridiculous feat of endurance. Secondly (and this holds for road cycling in general) there's so much game theory involved.

The biggest element of this is the effect wind resistance has on cyclists. I heard Chris Boardman commenting on some cycling recently that 80% of a cyclists effort is expended on moving air. There's obviously a lot of research that goes in to this and I found an interesting paper on the subject when planning on writing this blog:


In general road races have many more than just two cyclists but I'm only going to talk about two cyclists for now. This is for two reasons:
  1. Firstly this occurs fairly often. At some points in road races groups of cyclists "breakaway" from the main field and have to work together to stay away. 
  2. Secondly: the math is nicer with 2 "players".
Let's assume that two cyclists have broken away. Available to each cyclist is two strategies: {Lead, Follow}.  We make the following assumption:
  • If both cyclists Lead then it is assumed that they basically work alone (they both suffer the effects of air drag but make the speed of the slowest cyclist). 
  • If both cyclist Follow then it is assumed that they don't work at all and are caught by the peleton (their escape is basically over). 
  • If one cyclist Leads and the other Follows then they go at the speed of the Leader and the Leader fatigues.
We'll now write out some utilities that correspond to the above assumptions. 
  • Let  $v_1,\; v_2$ be the speed for each cyclist. 
  • Let $f_1,\;f_2$ be the fatigue felt by each cyclist when suffering the effects of air drag.

We assume the following utilities:
  • If both cyclists Lead then cyclist $i$ receives utility:
$$\min(v_1,v_2)-f_i$$
  • If both cyclists Follow then they both receive utility:
$$0$$
  • If one cyclist Leads and the other Follows then the Leader (w.l.o.g. let it be cyclist $1$) receives utility:
$$v_1-f_i$$

and the Follower receives:

$$v_1$$

This can all be represented in the following bi-matrix:


$$\begin{pmatrix}(\min(v_1,v_2)-f_1,\min(v_1,v_2)-f_2)&(v_1-f_1,v_1)\\(v_2,v_2-f_2)&(0,0)\end{pmatrix}$$


If we assume for now that $v_1=v_2=2$ and $f_1=f_2=1$ (we'll not get our hands messy with units) than our bi-matrix becomes:

$$\begin{pmatrix}(1,1)&(1,2)\\(2,1)&(0,0)\end{pmatrix}$$

Let $p$ be the probability with which cyclist 1 Leads and $q$ be the probability with which cyclist 2 Leads. It can be shown (using basic game theory and/or using this Sage interact (http://interact.sagemath.org/node/49)) that there are 3 equilibria for this game:
  • $(p,q)=(1,0)$ (Cyclist 1 always Leads)
  • $(p,q)=(0,1)$ (Cyclist 2 always Leads)
  • $(p,q))=(.5,.5)$ (Both cyclists Lead)
Using 1 of the pure strategies ($(1,0)$ or $(0,1)$) the utility to the Leader is 1 and the utility to the Follower is 2. Using the mixed strategy the expected utility to both cyclists is 1. Let us assume for the rest of this that cyclists use mixed strategies (i.e. neither takes advantage of the other).

In reality cyclists that break away cooperate, they talk and share the load as if they were a team. The mixed strategy above does not correspond to cooperation. It corresponds to a random strategy during which the cyclists will be randomly Leading and Following. Cooperation would be that both cyclists equally share the load (in a coordinated manner), the expected utility to both would then be 1.5 (both cyclists are better off if they cooperate - this is a notion quite close to my research, some screencasts of my talks are available here).

We'll continue to consider the situation in terms of a non-cooperative game as it gives an insight as to why cyclists cooperate.

We now assume that the cyclists are different. Perhaps they have escaped on a mountain stage and one of them is a better mountain rider. Let's take a look at the probabilities of Leading in a mixed strategy equilibria for varying $v_1$ (i.e. how fast the 1st cyclist is):




Basic game theoretical arguments give:

$$p=\begin{cases}1/2,&\text{ if }v_1\leq 2\\1/v_1,&\text{otherwise}\end{cases}$$

and

$$q=\begin{cases}1/2,&\text{ if }v_1\leq 2\\1-1/v_1,&\text{otherwise}\end{cases}$$

We see that as soon as $v_1$ is larger than $v_2=2$ the first cyclist has less of an incentive to lead. He/she basically "brings more" to the 2 cyclists and so the second cyclist must make more of an effort. 

This further emphasises the need for cyclists to work together when they breakaway.  

In reality cyclists would cooperate and the cyclist capable of helping the group stay away would perhaps work more.

A good example of a breakaway was the 2012 Olympic men's road race. The British team has one of the best sprinters of all time: Mark Cavendish. In road cycling, a sprinter is someone who is very good at going very fast over a shirt distance. Mark Cavendish is so good (he has recently been voted the best ever Tour de France sprinter) that no other team wants to be in a bunch finish with him: they'd lose. During this years race, the other teams all tried to put riders in breakaways. Normally other teams left in the peleton would at some point cooperate to accelerate the pace and bring the breakaway back in. In this particular occurrence no other team was good enough to beat Cavendish in a sprint and so no other team wanted to help (i.e. share time riding at the front) team GB. This is a slight over simplification as the Germans have a good sprinter who could have perhaps had a chance but it's not far off the truth. From a game theoretical point of view this make a lot of sense and in essence is exactly what happened. 3 riders formed a final breakaway and they contested the finish (Alexander Vinokourov won gold).

There's so much game theory in road cycling it really is a great sport to watch.

I've written a similar post applying game theory to rugby. For other recent blog posts with an Olympic flavour take a look at Paul Rubin's blog and Laura McLay's blog.