Thursday, 20 March 2014

Measuring Luck


Measuring Luck

In the story “A Dark Horse”, in the collection Northern Gothic Stories, Daniel Foster, a gambler, has a difficult time with lucky streaks, bad and good.   He worries that perhaps something more than the vagaries of random chance are at work, perhaps even something diabolical.

Anyway, a while back, I was locked into the deepest losing streak I'd ever known, maybe the deepest losing streak anyone has ever known. At least that's how it seemed to me.

I'd been six straight weeks without a winning day. Hell, at one point I'd gone fifty-seven straight races without seeing the cashier's window.  The odds against that must be astronomical.  A dead man could do better. I mean, pure dumb luck ought to count for something. At any rate, I was feeling pretty desperate.


My luck changed dramatically and all for the better.  It's been the hottest winning streak I've ever had, for all I know it's been the hottest winning streak of all time.

I don't know and at this point I really don't care. You see, this streak has been too much, too unreal for me to feel comfortable with.  I like to win.  Every gambler likes to win.  Hell, everyone likes to win, gambler or not. But this thing - I don't know. I think I preferred the losing streak.

The thing that's really got me are those damned dreams. Every night it's the same thing. They follow the script, the one I described before.  I get up and go to the desk.  The dark man refuses to tell me his name. We make a bargain, and we seal it with a drink. As I turn to leave, I hear the name of a horse.  The next day that horse is on the card.  If I bet the horse, he wins. If I don't bet he loses.  I've made over $200,000 in the last month alone, and I'm not even trying.  A horse player's dream, right? I'd give it all up for a good night's sleep.


 

I think we have all been through something like this in our lives, whether or not it involved gambling.  It can be exhilarating to be on a hot streak, and devastating to be on a cold streak.  It feels like the universe has singled you out, for better or worse.  So, just how do you measure how likely or unlikely a hot streak or cold streak is?

First off, it helps to have a well defined measure of success or failure.   In Daniel Foster’s case, it was success at the track, which can be measured in percentage of wins and money won or lost.  In other cases, it can be more nebulous - how do you measure “lucky in love”, for example?

So let’s stick with something easy.  In this case, we will look at the 20 year streak of ineptitude for Canadian NHL teams, in which they have not won a single Stanley Cup (to be fair, it is really 19, after excluding the lockout year).   Is this just a streak of bad luck, or is something else at work?

There are a number of ways to tackle this problem, so we will go in order, from “common sense” methods, to physical modelling (via playing cards), to computer modelling (via excel),  to theoretical mathematical methods (via the binomial theorem).  Pick the one you understand the best and like the best.

We begin by looking at what percentage of NHL teams were Canadian during this time span, which turns out to be 21.2% overall, varying from a high of 23.3% to a low of 20%.  So, naively, we would expect a Canadian team to win the Stanley Cup every 4 or 5 years, which corresponds to the proportion of teams in the league.  So, 19 years does seem like a pretty long time to go without a Stanley Cup.  Our naïve statistical sense tells us this is about 4 or 5 times longer than we would expect.  Carrying on further with our naïve statistical instincts, we might say:

·         There is roughly a 50% chance of a run of 5.

·         So, there is roughly a 25% chance of a run of 10 (half of 50%).

·         Then, there is roughly a 12.5% chance of a run of 15 (half of 25%).

·         Giving a 6.25% chance of a run of 20 (half of 12.5%), more or less.
So, using our naïve probabilistic reasoning, we think a run of 19 or 20 years without a Canadian team winning the Stanley Cup is a pretty low likelihood event (at about 6.25%), but not alarmingly so.  

  This reasoning isn’t actually valid, but I think it gives a feel for how people reason about things like this.  Plus, it does give an answer that is accurate, to a first approximation.  It tells us that we wouldn’t expect a run like this very often.

What’s our next effort to figure this out?

This time, let’s try an experiment, using a real-world situation to model our problem.   To do so, I took a deck of playing cards, and let the suit Clubs represent Canadian hockey teams (Montreal’s team is called the Canadiens’ Hockey Club, so I thought it appropriate to let Clubs represent the Canadian hockey clubs).  There are 13 Clubs in a deck of 52 cards, so they represent 25% of the deck.  If we remove the King and Queen of Clubs, then that suit has 11 cards out of the 50 remaining, representing 22% of the cards in the reduced deck.  That’s as close as we can get to the 21.2% of Canadian teams in the NHL during the period in question, so we will go with that.

So, now we take our modified deck of playing cards, and simulate the hockey problem by:
·         Shuffling the deck thoroughly.
·         Dealing cards out until we come to a Club, counting the number of cards as we do so.
·         Recording the length of the run of non-Clubs.
·         Repeat this as many times as you like (I did 100 trials).

My results are given below:

Run Length
Frequency
Percent
1
20
20%
2
18
18%
3
6
6%
4
13
13%
5
10
10%
6
5
5%
7
8
8%
8
3
3%
9
4
4%
10
3
3%
11
3
3%
12
0
0%
13
3
3%
14
1
1%
15
1
1%
16
1
1%
17
0
0%
18
1
1%
19
0
0%
20
0
0%
20+
0
0%
Total
100

 

As you can see, the longest run was 18, not quite as long as the number of years that Canadian teams have gone without winning a Stanley Cup.  So, it would appear that a run this long is less likely than our naïve statistical sense told us.  In fact, it appears that a run of 19 or 20 has a likelihood of coming up about once every 100 trials, at best.

For the heck of it, I tried this again, though this time I didn’t re-shuffle after hitting a Club, but dealt the deck on to exhaustion.  Basically, this was faster, though it wasn’t as statistically rigorous, since in any one shuffled deck, the short runs and long runs would be anti-correlated  (sort of like the idea behind card counting in blackjack).  Anyway, here are those results, this time using 250 trials:

Run Length         Frequency          Percent

 
 
 
1
47
19%
2
56
22%
3
27
11%
4
28
11%
5
25
10%
6
14
6%
7
13
5%
8
7
3%
9
6
2%
10
6
2%
11
3
1%
12
3
1%
13
5
2%
14
2
1%
15
1
0%
16
1
0%
17
2
1%
18
2
1%
19
1
0%
20
0
0%
20+
1
0%
Total
250

This time we hit one run of 19 and one run of 20+, so that’s 2 out of 250, or a little under 1%.  Surprisingly enough, the longest run was a run of 29.  It’s always weird to witness a such a low probability event happen before your eyes, even if it means very little in the real world.

So, I think we can safely say from the experimental evidence, that a run of 19 years without a Canadian team winning the Stanley Cup is a pretty unusual event  (odds are on the order of 1%), if it is just a matter of random chance.

I also set up a Monte Carlo simulation in Excel.  In that one, I simulated a 20,000 year NHL history (yes, it is a bit excessive), and counted how many times a run of 19 or more came, from random chance, given a Canadian team representation of 21.2% of all teams.  In 100 trials of this simulation, the median percentage of runs of that length was a bit under 1.0%.  That conforms nicely to our playing card experiment.

Finally, we can look at this as a simple binomial distribution probability problem (you may remember this from high school or university math courses), with p=.21 and n=19, and consult a table like this one:


Doing that, we also find the probability of a 19 year run of no Canadian Stanley Cups to be about 1%.

The nice thing about the playing card simulation, is that it is easy to understand and anyone can do it if they choose to spend half an hour or so shuffling and dealing cards (perhaps while watching their favorite Canadian hockey team scrub out of the playoffs).  You don’t need a strong math background, just common sense.

So, have we discovered whether the lack of success of Canadian hockey teams is just one of those things, or is there something deeper at work?  I suppose it is still a judgement call, but it does make you wonder.  Every year this goes on, makes you wonder even more.  We’ll leave it at that for now.

 

 

Friday, 14 March 2014

Astrophysics Corner, Part 7 - Happy Pi Day, from Dodecahedron Books (and a bit about Pi and Astrophysics, with a side-trip to the Dodecahedron)


As everyone no doubt knows, today is Pi Day.  That is, March 14 is Pi Day (it’s the fourteenth day of the third month, which is sometimes written as 3.14, the value of the transcendental number Pi, to two decimal places).

Speaking of Pi, here’s a bit from The Witches’ Stones Book 1: Igniting the Blaze that actually references Pi:

“I think I can get us into orbit before the Organization ship catches us,” Steph said.  “That might buy us some time, if I can keep the planet between us and the hounds’ ship.  We used to call it playing orbital tag back in training.  It’s a matter of matching speed and maneuver.”

Steph entered some commands into the navigation computer.  “It’s pretty simple, really.  When the distance between us and that ship is the same as pi times the distance between us and the planet, we break off into a circular orbit.  The hounds will have to do the same – they’ll have too much momentum to alter course and try to cut in front of our bow as we finished the first orbit.  Besides, even if they could do that, we’d see what they were up to right away and be in the better firing position to take them out with our bow-chaser laser cannon.  In the olden days, I think they called it having the weather gauge on the opponent’s ship.”

Basically, he is ensuring that he can maneuver his ship in such a way that he can get the Planet of the Amartos between himself and the better armed pursuing enemy ship, thus screening his ship from his enemy’s  fire.  Then, as long as he can keep the planet between them, his ship is safe, orbit after orbit (adjusting his orbit as necessary, when he detects that his opponent is doing so).  So, a bit of simple Pi-based  geometry still comes in handy in the 30th century.


Anyway, that’s the Pi-related book plug.  Now onto other interesting astrophysical and Dodecahedron Books related matters involving pi.

Naturally, astrophysics is full of matters that involve Pi (via circles, spheres, spirals, etc):

·         The fundamental forces, such as gravity and electromagnetism are 1/R**2 laws, that fall off equally in all directions (i.e. with spherical symmetry).  That’s the underlying cause of a lot of the things mentioned below.

·         Many orbits are circular, or close to it.

·         Same with ring structures, such as the rings of Saturn.

·         Stars, planets and other large bodies tend to become spherical if they have enough mass.  Indeed that’s one of the defining features of a planet, rather than an asteroid.

·         The rotation of astrophysical bodies around their spin axes is usually some variation of circular motion.

·         Galaxies often have a beautiful spiral symmetry.

·         The coordinate systems used to locate object in the sky are based on something called the celestial sphere, so Pi comes in there too.

·         Not surprisingly, much of the math used to analyse astrophysical data involves Pi, from geometry to trigonometry to advanced techniques like Fourier analysis and power spectrum analysis.

But what about Pi and the dodecahedron, you ask?  Is there a connection?  That’s a good question for a Dodecahedron Books blog on Pi Day, which we will address below.

Dodecahedron Books is named after the three dimensional geometric shape, the dodecahedron.  This is composed of 12 equal pentagons, which are folded up together into a beautiful characteristic shape.  A pentagon, of course is the two dimensional shape that is made of 5 equal sides, which is itself redolent of fascinating bits of mathematical arcana, mostly connected with a number known as Phi, or the golden mean.  There is a fair bit of lore, ancient and modern, about these shapes, which we will explore in a later blog.  For now, though, let’s focus on Pi, rather than Phi, and see if we can find a connection between Pi and the pentagon and/or dodecahedron.

You can inscribe a polygon (a regular two dimensional shape) in a circle, then inscribe that circle into another polygon.  Using the example of the pentagon, that process looks something like the picture below:

 
As you can see, the perimeter of the inner pentagon will be less than the circumference of the circle in which it is inscribed, while the perimeter of the outer pentagon will be larger than that same circle.  So, we would expect that the average of those two pentagon’s perimeters should approximate the circumference of the circle, more or less.
Let’s assume that the radius of the circle is equal to exactly 1 unit.  With a little high school geometry and trigonometry, we can see that the perimeter of the inner pentagon is given by:
2 X sin(36 degrees) = 2 X .58799 = 1.775571
There are five sides to a pentagon so the perimeter is =  5.877853


A little more high school geometry and trigonometry shows us that the perimeter of the outer pentagon is given by:

2 X tan(36 degrees) = 2 X .72654 = 1.453085


 
There are 5 sides to the outer pentagon, so that gives a total perimeter of 7.265425.
If we average those two, we get 6.571639.
The value of the perimeter of the circle is of course twice the radius times Pi, or:
2 X 3.1459 = 6.283185.
So, sadly our estimate isn’t really very close, differing from Pi by about 5%.  Oh, well let’s try something with more sides than dodecahedron, say an octagon (8 sides).  If we go through the same process, adjusting the size of the angles accordingly, we get an estimate for Pi of 3.18759.  So, that is considerably better.
Using a spreadsheet to carry this on, we get the following table for various numbers of sides for our polygons:
Number of Sides
Pi Estimate
Diff from Pi
Pct Diff
3
3.897114
0.755521663
24.049001%
4
3.414214
0.272620909
8.677793%
5
3.285819
0.144226797
4.590882%
6
3.232051
0.090458154
2.879372%
7
3.204104
0.062511599
1.989806%
8
3.187588
0.045995325
1.464077%
9
3.176957
0.035364046
1.125673%
10
3.169683
0.028090799
0.894158%
20
3.148189
0.006596400
0.209970%
50
3.142630
0.000330092
0.010507%
100
3.141851
0.000258602
0.008232%
500
3.141603
0.000010336
0.000329%
1000
3.141595
0.000002584
0.000082%
5000
3.141593
0.000000103
0.000003%
10000
3.141593
0.000000026
0.000001%
 
 
So, as you can see, the estimate gets better and better as we add more sides to our polygon.  By the time we have arrived at the 500-gon (100 times our original pentagon, which we could call the hecto-pentagon, because that sounds cool), the estimate for Pi that we get is almost indistinguishable from 3.14159, at 3.14160.  We are within one part in three million.
Interestingly, a graph of the above shows a function that looks a lot like our old friend, the power function.  It is interesting how that comes up in all sorts of places.  Of course, a mathematician might say that is a result of the fact that the trig functions can be approximated by power functions.  Indeed, you might say in this case, that Pi is baked right into the pie.

If we used this estimate of Pi for some simple geometry on astrophysical scales:
·         At the distance of the Earth to the Sun (one astronomical unit, about 93 million miles or about 150 million kilometres) we would be out by about 30 miles or 50 kilometres.
·         At the distance of four light years (a trip to the nearest star besides the sun), we would be out about eight million miles, or about twelve kilometres.
·         At the distance from the Earth to the center of the galaxy, we would be out about 40 billion miles or 60 billion kilometres.
·         At the distance to the Andromeda galaxy, we would be out about 4 trillion miles, or about half a light year.
 
So, if you are planning a really long trip, perhaps you should think of approximating Pi with a little more accuracy than the 500-gon can give you.

Friday, 7 March 2014

Whither Chapters 2 (and Whither Barnes and Noble too)


Whither Chapters 2 (and Whither Barnes and Noble too)

Indigo Books and Music Inc is the major corporation behind Canada’s big book chains - Chapters, Coles, Indigo and the World’s Biggest Bookstore.   I have written a couple of blogs about the fate of Chapters (or at least their recent results).  In this blog, I will update some data on them, and also add some data on the U.S. giant, Barnes and Noble.

Chapters
The first graph below shows the sales trajectory for Chapters from 1999 onwards (this data is widely available from online stock market information sources such as the Globe and Mail).  I show sales in both current dollars, and in inflation-adjusted dollars (in this case using 1999 as the base year).  As we can see, sales grew fairly nicely until about 2008 in inflation-adjusted dollars, then plateaued for a few years, before turning downwards in 2011.  With nominal dollars (not inflation-adjusted) the growth continued until 2011, then also turned downwards.  In that case, the growth from 2008 to 2011 was just books keeping up with general inflation.



The fact that sales in inflation-adjusted dollars hit their peak in 2008, then stayed there for a few years is probably a reflection of the worldwide financial crisis that happened about that time.   But the downturn from 2011 onwards is more likely due to the disruption of the book market by the widespread adoption of ebooks, which would have cut sharply into print-book sales.    A significant increase in self-publishing and Indie publishing went along with that, and Chapters has probably not seen much of that revenue, though they might have benefitted from some Indie sales through Kobo, as they do  continue to have close business ties with Kobo.  For those who don’t know, Kobo originated with Chapters, who then sold them to Japanese retailer Rakuten in 2011.

I should note that Dodecahedron Books published our first books, Kati of Terra Book 1 – Escape from the Drowned World  and The Witches’ Stones Book 1 – Igniting the Blaze in 2012, the first year of the major drop in Chapters’ revenue.  Is it mere coincidence that Chapters’ troubles started then?  I wonder J.
http://www.amazon.com/Kati-Terra-Book-One-Drowned-ebook/dp/B00811WVXO



We next look at operating expenses versus sales, and consequent operating income (operating profit or loss), in the graph below.  I have just included the inflation-adjusted graph lines, so as to simplify the picture.  As you can see, Chapters operating income dropped during the 2010 to 2012 period, eventually dipping below 0 in 2012, for an operating loss.  In 2013 they ground out a small profit, as their cost-cutting measures managed to overtake their revenue declines.  (Note - not sure if this graph will load properly into blogger).



The third graph shows operating income (profit or loss) at a more useful scale.  It is pretty clear that things took a nosedive after 2010, with a bounce back up in 2013.  Is this the infamous dead cat bounce?  (That’s a financial term that implies that one shouldn’t get too excited about a turnaround, because even a dead cat will bounce a bit after a big fall, but it doesn’t mean it’s getting back on its feet).

It’s hard to know that for sure.  Perhaps Chapters will be able to turn things around, though given the technological disruption that they are facing, it might not be a smart bet, if you are thinking of investing for the long term.  Companies can cut costs faster than they lose sales at the beginning by closing marginal stores, laying off inessential staff, selling unnecessary equipment (not sure if they have a corporate jet), and similar measures.  But most of those things can only be done once, so if sales don’t turn around, it just delays the inevitable.  As they say, you can’t shrink your way to greatness.




Barnes and Noble
Now, let’s look at the same set of graphs for the major bookseller chain in the U.S., Barnes and Noble.  The first graph shows sales (note that I could only find data from 2009 onwards for B&N).  It seems to be undergoing a similar trajectory to Chapters, with sales peaking in 2011, then dropping off.  The fact that their sales kept increasing for a year longer than Chapters’ sales did is probably due to the bankruptcy and closure of Borders, in 2011, which was their major U.S. competitor.   This may have only been a false bloom of health, though, given what happened in the next couple of years.  That is shown in the next graph, showing sales versus expenses and consequent operating profit or loss. (Note - not sure if the second graph will show - eating my graphs seems to be a law of the blogger software).




 
The third graph focuses in on the Operating Income figures (profit or loss).  It appears as if Barnes and Noble has not been quite as successful as Chapters at cutting costs faster than revenues fell.  There is no bounce, dead cat or otherwise in evidence.




So, what’s in store in the future for these major bookselling outlets?  Nobody can be sure, but below are some snips from recent European experiences (by the way, updated financials for Chapters Canada should be out in early April, 2014):

Chapitre (France)(Prensa Latina, Nove 28, 2013)
Paris, Nov 28 2013 (Prensa Latina) The French bookstore chain Chapitre announced today that it is filing for bankruptcy because it cannot maintain its book-buying and selling activities in the country.

The chain, which has 53 stores in France and some 1,200 employees, faces a difficult financial situation because of constantly falling sales, according to chairman Michel Resseguier.

Chapitre ranks second among businesses of its kind in France. It announced a restructuring program in April, including the sale of 12 facilities and staff cuts, but in late November it had only managed to sell four bookstores.

Its failure follows the liquidation of 26 stores of the Virgin Megastore chain in June, leaving 1,000 people jobless in several cities countrywide.
 

Weltbild (Germany) (Jan 14, 2014, Alex Shepard)

Weltbild, one of Germany’s largest publishers and booksellers, has begun insolvency proceedings, citing online competition—the Financial Times reports that it had initially warned investors in September “that high initial investments in its transition to online retail was resulting in temporary losses.” Last week, board member Peter Beer told the FAZ that the company’s struggles are a direct result of its failure to transition into the digital marketplace and compete with Amazon. Beer is also a priest—in fact, he’s vicar-general of Munich; Weltbild is owned by the Catholic Church.     
            
According to Weltbild’s website “every fifth book in Germany is sold through Weltbild.” The company currently employs 6,800 people and serves millions of Germans in its 300 shops. As of 2012 it had a yearly revenue of 1.59 billion Euros. Weltbild has previously claimed to be Germany’s second biggest online book retailer (Amazon.de is first) and its best known publishing company.