Monday, April 17, 2017

Venn diagrams and the meaning of English sentences



I was looking some English language materials recently and came across these two sentences. The basic question from the standpoint of understanding English was around the effects of commas and the meaning of similar statements in English. Thinking about it, it occurred to me that the question was about sets and logic as much as English comprehension. The original problem was stated similar to

In a certain math class there are Hardworking students and Lazy students. The class writes two tests. A student can Pass or Fail each test.

These are the overall results of the two tests.

1. The students, who were lazy, failed.

2. The students who were lazy failed.

Questions for students

- draw Venn diagrams with Hardworking, Lazy, Pass, and Fail for each of the two tests
- did any Hardworking students Fail the first test (yes, no, possibly)
- did any Lazy students Pass the first test (yes, no, possibly)
- did any Hardworking students Fail the second test (yes, no, possibly)
- did any Lazy students Pass the first test (yes, no, possibly)
- is it possible that everyone failed the first test?
- is it possible that everyone failed the second test?
- which test was probably harder? explain your reasoning


Now the first bit is English comprehension, as the only difference between the sentences is the punctuation. This part might be contentious so I put in my reading of the sentences. I'd be curious to understand how others may read it.

In the first sentence, my reading is: the punctuation makes laziness a property of those who failed the test.

In the second sentence I read it: the statement applies to the class as a whole.

So given that I can rewrite the sentences in an equivalent form that can be used for Venn diagrams

1 => 1.1 everyone who failed is lazy

2 => 2.2 everyone who is lazy failed

From there it's possible to create Venn diagrams and answer the questions.

I used creatly which was a nice online program. Easy to use and powerful. +1 to creately.

These are the Venn diagrams I came up with

For the first test

For the second test

Wednesday, March 29, 2017

Tim Horton's 100 challenge

Recently a few people have put the Tim Horton's roll up the rim challenge to the test. Apparently they are buying 100 cups of Tims coffee in an experiment.

I wonder what they were trying to discover. lol Tims is rigged? maybe they thought with 100 tries things would converge and they would have exactly 20 winners. In Tim Horton's roll up the rim they state that 1 in 5 cups wins something. The something is typically an inexpensive food prize such as a free coffee or doughnut.

I thought offhand 100 isn't a real large sample size and there would be some variance and probably surprises from people actually doing a sample of 100 times and recording the results. First I thought to write a script to use a random number generator to build a large set of samples of 100 trials (taking Tims at their word that indeed 1 in 5 cups randomly is a winner), then see what kind of data emerged.

Then thinking about it some more, I realized the chance of each of the outcomes, from 0 wins to 100 wins, can be computed exactly. This is the equation, where x is the number of times to win.

The probability of winning x times over a sample of 100 where each attempt has a 1 in 5 chance of winning is


This formula can be readily entered into Excel and we can determine the chance of each outcome. I entered it into a spreadsheet and these are some observations of the results.

The chance of losing all 100 times is about 1 in 4.9 billion. So any regular who tells you they never win is probably selectively forgetting a few stray wins here and there.

The chance of winning all 100 times is about 1 in 1070, or 1 in 7,888,609,052,210,030,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.

There is about a 1.26% chance of winning fewer than 12 times.

There is about a 1.12% chance of winning more than 29 times. So regulars who think they win about half the time are likely overestimating how often they win.

With a 1 in 5 chance each time, the expected would be of course 20 wins. There is actually a 9.93% chance of winning exactly 20 times, or more than 90% to get something other than 20. Most of the action is around 20, there is an 83.2% chance of coming in between 15 and 25 wins over the random sample of 100 cups.

Saturday, March 11, 2017

The end of the independent judiciary in Canada

Some recent court cases have called into question whether a judge in Canada can act as independent, impartial, disinterested observer in a criminal trial. In recent months in some court cases judges have been subject to censure after the trial for applying "incorrect" reasoning.

In an Alberta case a provincial court judge Robin Camp was subjected to a Canadian Judicial Council committee of inquiry who ruled that he "should be removed from the bench". The council also ruled that he "committed misconduct while presiding over the trial"

What was this misconduct? Judge Camp's mistake apparently was applying what some might consider thoughtcrime in his reasoning in acquitting a defendant of sexual assault.

With a precedent now established from the judge Camp case, now in a Nova Scotia case there are again calls to remove a judge over a sexual assault verdict, to send judge Gregory Lenehan to "Judicial council review". Again some disagree with the learned judge's reasoning in acquittal, and want the judge removed from the bench.

In the past there were concepts of an impartial judge, an unbiased observer with no personal interest in the outcome of a case. This allowed a judge to weigh the evidence as presented and determine a verdict free from outside pressure.

So what is the takeaway from this for judges and criminal defence lawyers? If I was a criminal defence lawyer with a client facing sexual assault I would not recommend my client go to trial by judge alone. Go with a jury trial. As we have seen, if a judge can be censured and kicked off the bench for acquitting, then it's hard to see how a defendant can get a fair trial by judge alone. If the judiciary is no longer independent then judges have to be aware of what the "expected" verdict and reasoning is before the trial begins. And they will be smart enough to protect themselves and deliver that verdict.

Even with a jury trial, it is still dangerous to the judge. His instructions to the jury could also be subject to this Judicial council review, so judges will be pressured to steer juries to deliver a predetermined verdict. Also once a precedent is established with judges, jury members as well can potentially face repercussions after the trial for coming back not guilty. So they will also now feel pressured play it safe and come back with guilty, to avoid trouble and possibly losing their day jobs as a result of delivering the "wrong" verdict.

The result of everyone having to play it safe is bad for defendants. In order for judges and juries to cover themselves and avoid difficulties after the trial if they acquit, established conventions would change. Presumption of innocence replaced by presumption of guilt. Burden of proof shifted to the defendant to demonstrate at least one of
a) the alleged crime did not occur
b) someone else committed the crime
c) it is impossible for the defendant to have committed the crime

Otherwise it might be "murky" as in the Halifax taxi case and better play it safe and protect your own interest and convict.

Friday, February 03, 2017

The Modern CBC Narrative

Interesting video posted by CBC 22 minutes apparently some time ago. Just saw it recently.


Intended as comedy, it's actually a sad and disturbing rendering of modern relationships. I suppose CBC has, as Canada's self-appointed storyteller, told the story of the modern Canadian man. Perhaps unwittingly but maybe not.

In the video a man comes home with a brand new truck that he bought. Before he even gets in the door of his own house he is attacked by his wife for buying the truck. Watch it in the video. A screaming, foul mouthed, public tirade against a man. The justification for her vicious attack? oh of course these invisible three kids.

Suitably shamed and humiliated, the video ends with the "man" agreeing to return the truck to the dealership for a vehicle of his wife's choosing.

Imagine for a moment CBC, doing it the other way. a wife comes home with some purchase husband disagrees with and is attacked as a result. yeah any day now we'll see that segment on 22 Minutes.

The poor guy and his 3 kids. loser should have never had kids or stopped after 1 with harpie. kids prevent him from doing the right thing and leaving her. 

For the guy, the 10 minutes that it took to drive the new new truck from the dealership to his house was probably the only 10 minutes of satisfaction he's experienced in the last 10 years being married to her. loser, he should leave her for disrespecting him. that's 10 minutes too much of his happiness for his wife to allow. so he goes back to the dealership, back to paying for everything, back to his job with it's prescription drug card.

Look at themes here. man attacked by his wife in public, openly berated, treated with hostility and contempt. the video is unfortunately so sad because it's not comedy. it's documentary, an accurate description of everyday life for all too many modern men. confirming and normalizing this type of abusive behaviour by women. The video is in poor taste.

Thursday, November 17, 2016

Let's Talk About Fake News

Nobody seemed too concerned about fake news back when CNN and the Clinton campaign worked together to stage a fake town hall for Hillary.

I guess #Gosnell is a fake news story as the mainstream media refused to cover it.

Who will be the arbiter of what news is real and what is fake? CNN, Brian Williams, Dateline NBC?

Facebook should hire Dan Rather as a consultant to weed out these fake news stories. Dan would know all about questionable news stories.

To me it comes across as pining for simpler times like the 1970s when News came from the big 3 TV networks, major daily papers like the New York Times, and Time/Newsweek. And that was it, that was the message. It's basically demanding Facebook, Google, YouTube etc., fall into line and join the mainstream media elite and do a better job of managing and filtering the stories, and delivering an expected narrative.

Tuesday, October 11, 2016

The Peril of the Baseball Wild Card Game

I didn't even realize it until this year with the Toronto Blue Jays. Apparently baseball expanded the playoffs to five teams from four. Previously it was the three division winners and a wild card. Then it seems in 2012 the playoffs were expanded to a second wild card team, which plays the higher wild card team in a 1 game playoff.

The addition of a wild card game definitely changes the dynamics of the playoffs. There is more emphasis now on winning the division and avoiding the jeopardy of a 1 game playoff. Anything can happen in one game.

Right now the Blue Jays are in good shape having swept their division series. But they were in a lot of danger in the wild card round. They were only 1 game better than Baltimore during the season, they were 11-16 in September, and Baltimore had won 2 of 3 off Toronto in Toronto just a week before. I'd say going in this game was pretty much a toss up or maybe with home field Toronto was at best a slight favourite to win this game.

It did get me thinking about the 1, 5, and 7 game series. The wisdom is that a longer series favours the stronger team. How much of a cushion does the 5 and 7 game series provide the better team. With a couple of reasonable assumptions it's not too difficult to actually calculate it.

Suppose x is the chance that the team we are hoping for will win any given game over the other team. So x then is a real number between [0, 1].

We know then that the other team's chance to win any game in the series is (1 - x).

For a 1 game series it's easy. The chance of our team winning the series is x.

For a best 3 out of 5 it is a bit more to think about. Our team can win the series in 3, 4, or 5 games. If you notice that our team always wins the last game, then you don't really care about what happened in the earlier games, you just count how many ways to get to that point before the decisive game. We only have to determine the number of ways to win the series. In any other outcome the other team wins and we lose.

So for a 3 out of 5, the chance of our team winning the series is
f(x) = x3(6x2 -15x +10)

In a 4 out of 7, it's the same process, this time we can win in 4, 5, 6, or 7 games. In a 4 of 7, the chance our team wins is
f(x) = x4(35 - 84x + 70x2 - 20x3)

Remember x is the chance that we win any given game.

With the formulas, we can plug them into a spreadsheet and see how much if any the longer series helps the better team.

This table shows the percentage chance that our team wins the series of that length for a given x.

x 1 game 5 game 7 game
0 0.0 0.0 0.0
0.50 50.0 50.0 50.0
0.55 55.0 59.3 60.8
0.60 60.0 68.3 71.0
0.65 65.0 76.5 80.0
0.70 70.0 83.7 87.4
0.75 75.0 89.6 92.9
0.80 80.0 94.2 96.7
1 100.0 100.0 100.0

So the longer series in fact does help the stronger team and there are fewer upsets. This is especially true when the better team is 60% or more to win a given game. There are a couple of things to note about this table.

Going from a 5 to a 7 game series doesn't help the better team a whole lot. Only about 3 times more per hundred series than they would win a 5 game series. So basically when the NHL and NBA made the first round 7 games it was just greed to have more games, not to help ensure that the better team advanced.

Also we can see why baseball changed the world series from 9 games to 7. The extra games don't materially affect the "discovery" of which team is actually better.

We can quick check the equations with the known cases of x= 0, 1, ½. When x is 0 the team has no chance and f(x) is of course 0. When we plug in x=1 the team is a lock and of course wins every time and the chance to win the series is of course 100%, as they win every game.

When x is one half, then each game is a coin flip. Playing extra games doesn't change anything. The result f(x) for the 1, 5, and 7 game series is exactly 50%.

--

From this we can see that there are cases such as x=0, that the chances in a 5 or 7 game series is the same as a 1 game series. that is f(x) = x.


Now for f(x) = x then f(x) - x = 0. For the 3 of 5 series this is

x3(6x2 -15x +10) - x = 0

This is a quintic equation so there are 5 roots. I was wondering about the other two roots. Since we know 0, 1, and ½, we can factor them out and with not too much work determine the remaining quadratic. It comes to

x(x - 1)(x - ½)2(3x2 -3x -1) = 0

The quadratic formula can be plugged in to yield the other two roots (3 ± √21) / 6. The roots are all symmetrical about x = ½.

These other two roots are in decimal approximately -0.26 and 1.26. So real numbers, but outside the defined probability range [0, 1].