lessCode.net
Links
AFFILIATES
Monday
Mar252013

Did Verisign revoke their own certificate?

image

Wednesday
Mar132013

Google is shutting down Reader

http://googleblog.blogspot.com/2013/03/a-second-spring-of-cleaning.html

Wait, what? This is Google’s best product, and they’re shit-canning it?

This has to rank up there with Fox’s decision to cancel Firefly

Friday
Feb012013

What’s My Super Bowl Pool Box Worth?

A bit of fun for this Super Bowl weekend. If you’re unfamiliar with a Super Bowl pool, the basics are simple:

Draw a 10 x 10 grid. One axis represents the AFC team, the other represents the NFC team. Participants pay a fixed amount for each of the 100 boxes. A payoff is set for each quarter of the game. Each row of the grid is randomly assigned a digit from 0-9, and likewise for each column of the grid. At the end of each quarter of the game, the final digit of each team’s score is used to determine the winning box for that quarter, and the owner of that box gets the loot.

The interesting question for box owners after the box numbers are assigned is: How much am I likely to win with these numbers? Moreover, if you’d entered the same pool every year since the Super Bowl began (ie. a pool with the same per-quarter payoffs), and happened to get the same numbers every year, how much would you have won in total? Obviously this is a contrived scenario, but an analysis of the history of Super Bowl scores makes for some interesting observations.

The nature of the scoring system in American Football is obviously the biggest factor in determining the “value” of a box: 3 (field goal) & 7 (touchdown + extra point), and their multiples, 6, 9, 4 and 1 seem likely to be winners. Also, the person who owns the 0-0 box stands to potentially win the entire pot before a ball is kicked or thrown, if two lousy offenses can’t score, or if the scoring goes in sets of touchdown, extra point, field goal. But if you think you have good numbers, a safety or a missed extra point are likely to ruin your day.

So, how much is my box worth in the above scenario?

// Per-quarter points scored for every superbowl - AFC,NFC
let quarterPoints = [
    ([ 0;10; 0; 0],[ 7; 7;14; 7]);
    ([ 0; 7; 0; 7],[ 3;13;10; 7]);
    ([ 0; 7; 6; 3],[ 0; 0; 0; 7]);
    ([ 3;13; 7; 0],[ 0; 0; 7; 0]);
    ([ 0; 6; 0;10],[ 3;10; 0; 0]);
    ([ 0; 3; 0; 0],[ 3; 7; 7; 7]);
    ([ 7; 7; 0; 0],[ 0; 0; 0; 7]);
    ([14; 3; 7; 0],[ 0; 0; 0; 7]);
    ([ 0; 2; 7; 7],[ 0; 0; 0; 6]);
    ([ 7; 0; 0;14],[ 7; 3; 0; 7]);
    ([ 0;16; 3;13],[ 0; 0; 7; 7]);
    ([ 0; 0;10; 0],[10; 3; 7; 7]);
    ([ 7;14; 0;14],[ 7; 7; 3;14]);
    ([ 3; 7; 7;14],[ 7; 6; 6; 0]);
    ([14; 0;10; 3],[ 0; 3; 0; 7]);
    ([ 0; 0; 7;14],[ 7;13; 0; 6]);
    ([ 7;10; 0; 0],[ 0;10; 3;14]);
    ([ 7;14;14; 3],[ 0; 3; 6; 0]);
    ([10; 6; 0; 0],[ 7;21;10; 0]);
    ([ 3; 0; 0; 7],[13;10;21; 2]);
    ([10; 0; 0;10],[ 7; 2;17;13]);
    ([10; 0; 0; 0],[ 0;35; 0; 7]);
    ([ 0; 3;10; 3],[ 3; 0; 3;14]);
    ([ 3; 0; 7; 0],[13;14;14;14]);
    ([ 3; 9; 0; 7],[ 3; 7; 7; 3]);
    ([ 0; 0;10;14],[ 0;17;14; 6]);
    ([ 7; 3; 7; 0],[14;14; 3;21]);
    ([ 3;10; 0; 0],[ 6; 0;14;10]);
    ([ 7; 3; 8; 8],[14;14;14; 7]);
    ([ 0; 7; 0;10],[10; 3; 7; 7]);
    ([14; 0; 7; 0],[10;17; 8; 0]);
    ([ 7;10; 7; 7],[ 7; 7; 3; 7]);
    ([ 7;10; 0;17],[ 3; 3; 0;13]);
    ([ 0; 0; 6;10],[ 3; 6; 7; 7]);
    ([ 7; 3;14;10],[ 0; 0; 7; 0]);
    ([ 0;14; 3; 3],[ 3; 0; 0;14]);
    ([ 3; 0; 6;12],[ 3;17;14;14]);
    ([ 0;14; 0;18],[ 0;10; 0;19]);
    ([ 0; 7; 7;10],[ 0; 7; 7; 7]);
    ([ 0; 7; 7; 7],[ 3; 0; 7; 0]);
    ([ 6;10; 6; 7],[14; 0; 3; 0]);
    ([ 0; 7; 0; 7],[ 3; 0; 0;14]);
    ([ 3;14; 3; 7],[ 0; 7; 0;16]);
    ([10; 0; 7; 0],[ 0; 6;10;15]);
    ([ 0;10; 7; 8],[14; 7; 0;10]);
    ([ 9; 0; 6; 6],[ 0;10; 7; 0]) ]

// Dollars to win at the end of each quarter
let prizes = [| 50; 125; 75; 250 |]

let total points = Seq.scan (fun t p -> t + p) (List.head points) (List.tail points)

let modulo = fun i -> i % 10
let modulos points = Seq.map modulo (total points)
let quarterModulos = Seq.map (fun (afc, nfc) -> modulos afc, modulos nfc) quarterPoints

let payoff : int[,] = Array2D.zeroCreate 10 10

let payQuarter (afc, nfc, prize) = payoff.[nfc,afc] <- payoff.[nfc,afc] + prize
let payGame (afc, nfc) = Seq.iter payQuarter (Seq.zip3 afc nfc prizes)

Seq.iter payGame quarterModulos

payoff

This snippet is also runnable at tryfsharp.org. The results are interesting:

image

43% of the possible outcomes seem to have never occurred in the Super Bowl.

0 and 7 are indeed big winners, and 7 – 4 is by far the most valuable box. However, its reciprocal 4 – 7 is one of the least valuable of the winning boxes.

Tuesday
Jan292013

Another Simple Way to Tinker with F#

From Microsoft Research – tryfsharp.org, a very cool site for testing and sharing F# code, complete with a built-in JavaScript charting engine. I just posted the Discount Curve sample to try it out.

Can’t figure out how to get the time axis to render dates, though - the DoJo chart needs the data to be numeric, and I don’t see a way to use a label function to do the conversion back to date, although the library itself seems to support it

Tuesday
Aug072012

How strong are your development standards?

Having worked for a number of years on real-time process control systems (think: device drivers and management information applications for monitoring and controlling large-scale industrial processes such as oil & gas refinement, chemical and food production, etc.), the recent years I’ve spent working on financial software systems have highlighted quite a few differences for me with regard to how the two industries approach quality assurance.

Going into finance, I had a certain expectation that there would be many aspects of the discipline that would align quite closely with those of process control – the quantity of data to manage; the timely calculation and analysis of statistics; the automation of feedback control in response to stimuli, etc. – all would seem to be equally important when opening and closing valves and switches as they are when buying and selling financial instruments.

Human beings can die as a result of a hardware or software glitch in a critical control system of an industrial process. Back when I was working in that area, hardware and software manufacturers usually tended to be very much concerned about the quality of their offerings, and purchasers of those products almost always tested the crap out of them for long periods before trusting them in production. [Not so much for the management information systems, but certainly for the low-level stuff].

The catastrophic failure of a trading system (as we saw recently with a certain Knight Capital) is not, let’s face it, going to literally kill anyone, but the costs of those failures can adversely impact a great many people in many different ways. One would think that quality assurance, software testing and development standards would be of great importance in these systems, too. But my experience in finance has suggested to me that that is often not the case.

Anecdotally, I get the sense that the problem is perhaps worse with the in-house developments of practitioners (banks, funds), than it is with the products of ISVs, but really not by much, maybe because there is often much migration of personnel between the two.

And then, this week, having sent a device that’s roughly the size and weight of a Mini Cooper through space for nine months, we parked it safely on Mars. I say we, meaning human beings, but it was really mostly down to a select bunch of humans much smarter than we, over at NASA. Maybe it’s just me, but I’m still amazed that something like this is possible by the same species that gave us the Synthetic CDO.

So, what kind of development standards are required in order to pull something like this off? [Meaning the Mars thing, of course, and not the CDO thing.]

Some of them are right here, take a look: JPL Institutional Coding Standard for the C Programming Language

It’s a fantastic read – clearly written, very approachable and not long or dense (20 pages or so) -- but here’s the summary:

image

How do your standards measure up? Are they even documented as nicely?