lederhosen: (Default)
So after yesterday's post I thought I'd extend it a little and test my code on a full-sized problem: casting Hamlet.

This helpful site lists the characters present in each scene, although you have to be a little careful - Claudius is also listed as "King", and Gertrude as "Queen". In some cases it just lists groups ("Assistants", "Clowns", etc.); for this work I've just assumed there are two of each, though you'd want to check that. This results in 39 parts.

I entered that data, along with some made-up numbers for how many lines each part has; the exact values don't matter too much, as long as there's enough info to distinguish between major and minor parts. I also tweaked it so that minor characters are assumed to have 5 lines each unless specified otherwise, which saves on data entry.

Unfortunately the demo license for AMPL doesn't allow me quite enough variables to solve this problem. (I could probably reformulate it to reduce it to one variable per part, plus a few extra, but that would be a bit messier.)

Not to fear, there's another option: NEOS. NEOS is a web service that allows anybody to submit optimisation jobs for free, without a size limitation... and it accepts AMPL format. Having tested and debugged my code on a smaller problem, I can then add the full Hamlet data and submit it to NEOS at this page.

I upload three files:

castingmodel.mod )

hamlet.dat )

Last, a commands file to tell NEOS what output I want:

casting_commands.txt:

solve;
display Casting;


I then enter my email address and click "submit". In a minute or two, NEOS shows me the results, which you can view for yourself, and also emails me a copy. (A result of "infeasible" would indicate that it's impossible to satisfy the problem as specified, either because of some inconsistency within the constraints or because there aren't enough actors.)

The output shows some information about the solution process, and at the bottom it gives the final casting:

Art: Guildenstern
Bea: Barnardo, Clown 2, English Ambassador, Player Queen, Reynaldo
Chris: Hamlet
Derek: Horatio, Player Lucianus
Eve: Doctor of Divinity, Fortinbras, Laertes Follower 2, Player King
Frank: Ophelia
Greg: Polonius
Hugh: Gertrude
Irene: Francisco, Gentleman, Lord2, Osric, Voltemand
Jo: Claudius
Kate: Clown 1, Rosencrantz
Luke: Laertes, Player Prologue
Meg: Captain, Cornelius, Laertes Follower 1, Lord 1, Sailor 2
Ned: Attendant 2, Ghost, Lucianus
Oli: Attendant 1, Guard, Marcellus, Messenger, Sailor 1

This looks pretty sensible overall: most actors either get one big part, or a bunch of small parts, and our choices for Hamlet and Laertes satisfy the fight training requirement.

Nerdgasm

May. 26th, 2012 10:22 am
lederhosen: (Default)
Via Weaselking: Conway's Game of Life used to run Conway's Game of Life.

(More on the 'metapixel' used to power this here.)

Bzzzzzz

Feb. 2nd, 2012 06:15 pm
lederhosen: (Default)
Watching this video, I am torn between "AAAAAAAH DO NOT WANT!" and "Awesome!"
lederhosen: (Default)
Thing 1: I've been doing the free machine learning e-course from Stanford. I can thoroughly recommend it* and if you missed it there's another offering in January.

Thing 2: Stanford are also offering a whole bunch of other free online courses. The PGM one looks like it might be work-relevant, and I think I might do the game theory one on my own time.

Thing 3: The course forums are pretty good, in general, but there's this one guy who makes me cry every time I see his comments. In this case, the OP produced a graph that looked good near the fitting points, but produced negative results (nonsensical in context) elsewhere**. Response, in the original punctuation:

HOLY FLOW CHARTS....I have never have seen negative Water Flow Across a DAM... When the Level Transmitter shows a ZERO LEVEL....you only get SPLASH flow across the Dam (wind and waves cause Splashing). A secondary flow sensor should pick up this random flow. When the Level Signal goes positive you should get a flow signal that follows Weir Flow Charts...I think it is a 3/2 or 5/2 power or something in between depending on how it is constructed.

Modelling it with a Chart showing NEGATIVE FLOW would get you FIRED...recommend erasing everything < than "ZERO" FLOW...the Stanford computers might pick that up as an ERROR in the CALCULATIONS...


Translated into English: "You should censor the results that are obviously wrong, to make the graph look better, without considering what those results might imply for the accuracy of the other results that don't LOOK wrong."

...and that, right there, is a "I would never ever hire you" button.

*although I still don't like their explanation of back propagation - not sure whether I've misunderstood it, or whether it's just a bad explanation of something that should just be "calculate the gradient of the cost function".

**Kids, JUST SAY NO to extrapolating from eighth-order polynomial fits. Please.
lederhosen: (Default)
I love these so much:

http://www.gaussfacts.com/

"As a child, Gauss was instructed to sum the numbers from 1 to 100. He did this by summing the infinite series and then subtracting off every integer greater than 100, one by one, in his head."

"When Carl Friedrich Gauss adds one, his number doesn't increase, all other numbers become smaller."

"Gauss shaves both himself and Bertrand Russell."

"Gauss has an Erdos number of -1."
lederhosen: (Default)
Rey and I are gradually working through our moving boxes, unpacking stuff to keep and picking as much as we can for garage sales/rubbish, because we have Way Too Much Stuff.

Today, my old programmable calculator (HP 20S). I didn't use it for academic work much because they didn't allow programmables*, but I'm fond of it. I won it in a maths competition, and I used its 100-line memory to create a dice roller for D&D.

Now of course it's hopelessly obsolete, but I still feel bad about just tossing it in the bin. Does anybody run a Home For Old Calculators or something?

*Except for the maths department at ANU, who had a fairly liberal open-book policy.
lederhosen: (Default)
Spent a large chunk of today on the phone to one of our SAS support guys discussing a problem I've been having with one of my programs*. Ended up sending him the program + logs so he could look through it for himself, and he actually called it a "work of art". Go me!

He might have been thinking Picasso, or possibly Escher's "Ascending And Descending" given how long the wretched thing takes to run, but I shall take it as a compliment.

I know I'm not a real programmer, but in the course of developing some SAS training courses I've learned a little bit along the way... also, developed a sense of "if I am telling newbies how to write programs I probably ought to take some of my own advice" type guilt, which is a powerful motivator to plan, document, and validate.

The stupid thing is that I'm pretty sure this program was working two weeks ago; the thing that's been giving me all this grief is the validation step that confirms that it works in practice as well as in theory. Apparently non-optimisable SQL joins are a bad thing when the tables involved each have about a million entries... but I have wrestled it down to the point where it only takes about 10 hours to run and about a gig of memory!**

*I am about 95% sure the cause of the problem is "some other process, probably their automated backups, decided to put a lock on one of my files at the same time my program needed to write to it", but they wanted to explore other options.
**Which would be why I end up running it at night, at the same time the automated backups happen...
lederhosen: (Default)
Sad moment: Archive-bingeing a newly-discovered webcomic, and spending several minutes trying to get past a broken 'next page' button before realising that no, the button's not broken, that's all there is so far.*

Sadder moment: It only updates once a week? O NOES!

(In two days' time, we can has house of our own! Hooray!)


*I only figured this out after attempting to guess URLs. That said, I've encountered some comics where URL-guessing really did let me see several days into the future...
lederhosen: (Default)
Once upon a time, the usual explanation for parapsychology "findings" was bad experimental technique (subjects were getting cues as to the correct answer, that sort of thing). Sometimes due to deliberate dishonesty, often because experimental design is hard.

These days, experimental technique has tightened up a lot, due largely to sceptics and partly to those parapsych researchers who think they've got something and want to be taken seriously.

This has established that if psi effects exist, they're weak*. If we had psychics who could predict the outcome of a coin-toss with 100% accuracy - or even 55% - one of them would long ago have claimed James Randi's money. To detect weak effects, you need to run very large experiments containing thousands or millions of trials, and perhaps apply sophisticated statistical techniques to analyse the data.

The problem with this is that with a large data set and a lot of choices about how to perform your analysis, it's awfully easy to cherry-pick for significance. So, my suggestion is:

Every time a human subject generates a data point (makes a prediction, etc etc), we should use a random number generator to generate, say, a thousand fake versions of the same data point, all consistent with the null hypothesis. From these, we form one real data set, and a thousand fakes.

Stats analysis is then performed blind - the statistician decides on appropriate analysis techniques without knowing which is the real data set. The decision on journal publication is also made blind; only after the article is irrevocably committed to publication does anybody get to find out whether the 'significant' data set identified is the real one.

This wouldn't fix all problems with parapsych research (and depending on the nature of the data, it might take some work to generate fake data that can pass as the real thing) but I think it would be useful in many cases. This needn't be restricted to parapsych; I'm pretty sure there are other fields that would benefit from this too.

*I'm not inclined to dignify the "we have strong psi powers that completely vanish under fraud-proof conditions" argument with a response.
lederhosen: (Default)
So, this story about Daryl Bem's alleged experimental evidence for precognition has been doing the rounds.

I was going to launch into a lengthy post about the problems with this experiment, but four Dutch researchers have already produced a very good response that covers all the points I was going to make and several more.

In brief: when you have a large long-running experiment and you get to chose the analysis techniques, exclusion criteria, and the stopping point after looking at the results, it is really easy to find 'significant' patterns.

One of my favourite demonstrations of this is Brendan McKay's 'Bible Code' work, in which he shows how 'Moby Dick' predicted the assassinations of Indira Gandhi, JFK, Rene Moawad, Leon Trotsky, MLK, Yitzhak Rabin, and others.

Maths stuff

Aug. 4th, 2010 06:33 pm
lederhosen: (Default)
Why did nobody tell me Kate Bush had recorded a song about my father?

Have been doing a training course with James Brown for the last two days. He is rather less soulful and more mathematical than his namesake. I have to say, until yesterday I don't think I'd ever heard the f-word used repeatedly in a maths lecture, but it was in a cheerfully enthusiastic sort of way.
lederhosen: (Default)
In case anybody doubts that 7x13=28, I wrote some SAS code to test it:

%let officers=9+4; /* 9 lieutenants, 4 captains */
%let donuts_per_officer=4+3; /* 4 plain, 3 fancy */

data total_needed;
officers=&officers;
donuts_per_officer=&donuts_per_officer;
total_donuts_needed=&officers*&donuts_per_officer;
run;

Result confirmed!
lederhosen: (Default)
One of the things I like about Settlers/Cities & Knights of Catan is that dealing with randomness is a big part of the strategy (as opposed to things like Fluxx, where you can't really plan ahead past the next turn or so). I'm quite fond of prob-theory, so that works nicely for me.

I'm probably overanalysing this game... )

Fun stuff

Apr. 6th, 2010 11:52 pm
lederhosen: (Default)
I had a good Easter break. Rey and I picnicked at the Organ Pipes National Park, which has some nifty-weird volcanic formations*, and [personal profile] 17catherines led us in a reading of Romeo and Juliet. Rey made marzipan thumbs specially for the occasion!

Tonight, Rey and I went to see Tripod and Elana Stone in 'Tripod versus the Dragon', a D&D-based musical. This was one of the nerdiest evenings of my life, which if you know me is saying something. It was also really good; lots of laughs and some beautiful songs mixed in with the comedy. Very strongly recommended if you're in Melbourne or Sydney.

Also, I discovered that YouTube has lots of Monsterpiece Theater. Cookie Monster makes me happy.

...and one of these days I will post a gaming update, and the monstrosity Rey has commanded me to write. When I get around to finishing them. But for now, bedtime.

*I found Rey a book about volcanic activity in Victoria. We will never again want for ideas on where to picnic.
lederhosen: (Default)
It's probably a sad thing that my first reaction to this theoretical ecology of vampires is neither "who cares", nor "wow, that's cool", but "wait, I think there's an error in that first expression".
lederhosen: (Default)
Watch the computer think as you play chess against it. Very pretty!

(The sad thing is, I *still* got thrashed...)
lederhosen: (Default)
For your entertainment, inspired by a protracted debate with our SM1 lecturer. The basic idea of these questions isn't original to me, but I've modified them somewhat to make the phrasing less ambiguous.*

1. A friend mentions that they have two kids. With no other information, what are the odds that they have (a) two boys, (b) one boy and one girl, or (c) two girls? (For the sake of these problems, assume that half of children are boys, half are girls, and people don't have a natural tendency to children of one sex or the other.)

2. Looking at one of their many bookshelves, you spot a Saddle Club book, which (applying gender stereotypes) you may take as indication that at least one of their children is a girl. Based on this information, what are the odds that they have (a) one boy and one girl, or (b) two girls?

3. You mention the Saddle Club book to your friend. He replies "Yeah, that's Mary's." What are the odds that both their kids are girls?

4. As above, but the reply is "Yeah, that's Mary's, she's my eldest."

5. Different friend, same dilemma - two kids, you don't recall their sexes. Being sneaky, you ask "Would your oldest like to come to my kid's birthday party?" and the response is "Yes, she'd love to." What are the odds that both their kids are girls?

6. As above, but the response is "Mary? Yes, she'd love to."

7. You find a Saddle Club book lying on the ground, inscribed 'To Mary'. You ask around the local schools and in a flagrant breach of privacy they give you the addresses of several dozen Saddle-Club-age 'Mary's in the neighbourhood. You go to the first house on the list and, by examining shoes again, deduce that the family has two children. What are the odds that both are girls?

*Which was surprisingly difficult to do - it's actually very hard to convey no more and no less information than one means to when writing these things.
lederhosen: (Default)
(Partly, I think, suggested by a passage in Oliver Sacks' Uncle Tungsten in which he discusses music and the periodic table.)

I know several of my artistic friends are tired of hearing lines like "You're so lucky to have that talent!" when a big part of their 'talent' comes not from luck but years of hard work.

For most media, that's the nature of art - people won't see the hard-earned technique unless they actively look for it, but the creative aspect is there for all to perceive. You can look at a Renoir and enjoy it without knowing a thing about Renoir's painting technique; you can listen to Beethoven's Ninth Symphony and feel its beauty and vibrancy without the faintest idea of how to read music, much less how to score for an entire orchestra.

Beethoven, of course, was deaf.

By the time the Ninth was finally performed, he was so utterly deaf that he was still attempting to conduct it several bars after the orchestra had finished, and he had to be turned around to see that the audience were applauding. For him, I presume, technique was the only medium through which he could know what he was writing, and hear it, if not with his ears, then at least in his mind.

Mathematics is a little like that. At first, the technique relates to things that we can perceive directly - we can lay out apples in a square, two by two, and see that two-squared is four; with a little bit of balancing, we can sit another layer of apples on top of the first four and see that two-cubed is eight. This is something comparable, perhaps, to playing a few notes on a scale and hearing what they sound like.

But take it a little further - what about two-to-the-fourth? - and we can't see it any more. We can still build physical analogies of one sort or another (imagine a second apple inside each apple, perhaps?) but they swiftly become so complicated or so bizarre that we can no longer visualise them in a way that lets us grasp the work we're trying to do; we have to build it inside our heads, a strange sort of shape beyond anything our physical senses can capture.

For the last six months, I've been working on a multi-stage sampling project, immersed in the mathematics that involves; I wish I could describe how that feels inside my head. It's a little like a telescope, with four or five stages that fold into one another; it's a little like an orrery, with a cloud of tiny satellites - each of them, viewed from a certain angle, represents a person - orbiting a swarm of invisible moonlets, which in turn orbit moons, each captive to a planet, each planet captive to the invisible sun at the heart of the system. But it's not really any of these things; trying to describe these structures in terms of things we can see is like trying to turn paintings into music.

So the only way I can share that with anybody else if if they've learned the relevant technique - and even then, they'll need to spend some time staring at the dry equations in order to go from 'notes' to 'music'. I suspect this is part of the problem: most people never get enough exposure to the technique that they're able to get past it to see what it represents. It's like staring at a Pointillist painting, and seeing only a sea of coloured dots.

To get very far with mathematics, you need to reach that level of comfort with the underlying technique, internalise it and practice to the point where you can forget it. I can learn how to press a key on a piano and produce a note of whatever pitch and volume I want, but that isn't enough to make me a musician**; knowing the rules of logic is vital as a first step in mathematics, but it doesn't take me very far on the road to doing what I want in the medium. A musician can listen to music they've never heard before, and guess what the next notes will be; there are similar instincts at work when I'm doing my job. Logic tells me what steps I can and can't take, but instinct guides me in choosing which of those countless possibilities will get me closer to where I want to be. It is a creative process in its own fashion, and knowing where that process will begin and end doesn't detract from that creativity, any more than painting loses its creativity when you're looking at a model.

Not, of course, that the distinction between 'technique' and 'creation' is sharply drawn. In mathematics especially, yesterday's creation is tomorrow's technique - and sometimes technique, picked apart and re-evaluated a la Godel etc, becomes creation again.


*Mind you, a good knowledge of technique almost always increases the ability to appreciate art - it's just that you can get a long way even without it.
**Sadly, I had almost ten years of piano lessons without ever really figuring out that there was more to music than pushing the keys in the right way at the right time.

Profile

lederhosen: (Default)
lederhosen

April 2017

S M T W T F S
      1
2345 678
9101112131415
16171819202122
23242526272829
30      

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 28th, 2017 08:24 pm
Powered by Dreamwidth Studios