Thursday, October 8, 2015

Eight versions of Arthurian legends I've seen

Sword in the Stone (1963)
Based on the first book of T.H.White's tetralogy, which was the best version of King Arthur in the twentieth century, in my opinion. Everything good in this version comes from the source material.

Camelot (1967)
Based on later parts of the same book! My favorite moments are when Lancelot brings back to life the knight he has accidentally killed, and when Arthur lays dying and says “Don't let it be forgot, that once there was a spot, for one brief shining moment, that was known as Camelot.” That brings tears to my eyes.

Monty Python and the Holy Grail (1975)
A hilarious if really uneven spoof. More quotable lines than any other movie. Probably too quoted. The truth is, in some ways this is closer to Mallory than most versions, in the way it seems to wander all over the place fighting and not going anywhere with the plot.

Excalibur (1981)
Fantasy movies in the 1980s were really hard to do right. The desire was there but without CG, it was really difficult to do believable magic. This is probably the truest to Mallory, and its devotion to mythology makes it seem strange. I like the super-heavy jousting plate they all wear all the time, though of course it's historically far too late.

First Knight (1995)
I adore the scenery, acting, and costumes in this version. I could watch Sean Connery, Julia Ormond, and Richard Gere all day. The plot is totally ruined and the characters are all wrong as they try to make it more Hollywood, though.

Merlin (1998 miniseries)
What a mess. The depiction of the villains was so badly done I still get the shivers thinking about it. Acting all in front of green screens, and changing the ending to make it happy. It had a few moments but was overall a failure.

King Arthur (2004)
This was an attempt to dramatize a plausible historical interpretation of Arthur as a post-Roman warlord struggling to keep civilization alive. It features Keira Knightly as a warrior Celt version of Guinevere. Good riding into battle scenes. Christians in the film are horrible people, just because Hollywood.

Merlin (BBC One)
I might have liked this better when I was younger, but I just don't like TV that much, so I only watched a few episodes. It's too modern in attitude. It seemed kind of like a Jocks vs Geeks high school series set in the middle ages. But I might not have given it enough credit.

Eight versions of Robin Hood I've seen

These are listed in temporal order.

Robin Hood (1938) Stars Errol Flynn. The climactic swordfight scene stands out as very exciting and well choreographed.

Robin Hood (Disney animated): This movie was made on the cheap, and it shows. For some reason Baloo and Hiss from The Jungle Book are just dressed up for this. For the sake of humor, they used some very American comic actors mixed with others doing straight British accents, which just comes across as weird. If you speed up the oodalolly song it turns into the hamster dance song. There are some interesting connections to the French sequence of tales about Reynard the Fox.

Robin and Marian (1976): Sean Connery and Aubrey Hepburn at the end of Robin's life. It's slow and moody, but the acting is really well done, and it doesn't just replay the same old material. It's a movie about love and getting old. Neil Gaiman references it in Whatever Happened to the Caped Crusader?

Robin Hood: Prince of Thieves: The visuals (sets, costumes, cinematography) and soundtrack are probably the best of any version, if you don't care about accuracy to the time period. The acting is terrible. It adds in a witch and an attempted rape for no good reason.

Robin Hood (1991): Completely overshadowed by Prince of Thieves, this made-for-TV version is one of my favorites. It's more historically accurate, for one thing. It stars Uma Thurman as Marian, features longbows, and ends with peace with the Saxons, which is historically the way Britain went. There's no Sheriff or Prince John. Let me know if you find a blu-ray version.

Robin Hood: Men in Tights: Like all Mel Brooks movies, unbelievably stupid. "Ay, Blinken! Did you just say Abe Lincoln?"

Robin Hood (BBC One series): pretty forgettable, but if you want a British miniseries about Robin Hood, this one is decent. The characters seem like modern people.

Robin Hood (2010): Russel Crowe is the main selling point for this movie. It's actually a Robin Hood prequel, though it isn't advertised that way, which makes it feel badly paced.

Wednesday, July 1, 2015


Here is a diagram of what imagery we can expect in the next two weeks from the New Horizons Pluto probe:

And if you want to see the new images as they come in, the best place to go is here:

Pluto has very bright and dark regions on it. Does it have a giant mountain range running all the way around the equator? Giant impact basins? We will know soon.

Sunday, May 24, 2015

evil, evil, evil, evil dogs

Things that are the same in high dimensions

I have a set of high-dimensional vectors. These vectors are distributed as a gaussian surrounding zero in all the dimensions. I choose two of those vectors, perform an operation on them, and search for the nearest neighbors among the set using Euclidean distance. The following operations all tend to return the same neighbors:

The sum
The average
n * the sum, where n is large enough (something like 0.25 to infinity)
The vector product (I think that's what it's called)
The element-wise maximum
The element-wise minimum
The sum of the element-wise sign function (e > 0 : +1, e < 0 : -1)

All of these basically give me something that is approximately a 50/50 mixture of the elements of the two vectors. Each of the elements of the result vector will resemble an element of one of the two input vectors. The multiplier n can be as large as you like because after a certain point, it's just saying "whatever is furthest out along that direction."

If you think of a simpler version of the same situation, it is easier to see what is happening.  Let all the coefficients be +1 or 0, still distributed as a half-gaussian. Then you can think of the values that happen to be +1 as "words" which "define" the vector. The result of any of the above operations will give you a definition that includes words from the definitions of both the inputs, and no others.

I think I could prove this mathematically, but maybe someone knows of a proof already I could use as a reference?

Friday, April 10, 2015

New planet candidates

The following three planets look like really good possibilities for life. In general, with a radius larger than Earth, one hopes for a temperature lower than Earth's, expecting a thicker atmophere. All three have suns that are close to the same temperature as our own, but the first two are smaller than our sun (.8 x) and the third is larger (1.2 x).
None of these have been announced on the news because they like to wait for confirmation.

These are different from earlier reports because they are orbiting yellow stars, like the sun, rather than orange or red stars (which are smaller and cooler).

Year in Earth days
Radius in Earths
Temperature relative to Earth's
KOI 7016.01
35 C lower
KOI 7235.01
18 C lower
KOI 7179.01
17 C higher

EDIT: On July 23, NASA announced that KOI7016.01 was confirmed. It's new name is Kepler 452-b. As of that date it was the most Earthlike planet found so far. The new radius is 1.6 and the new estimated temperature is higher than Earth.


I imagine everyone's favorite music comes from when they first begin to discover it on their own. Growing up, I listened to whatever eclectic variety the rest of my large family brought home-- Andrew Lloyd Webber, Holst, Simon and Garfunkel, Bon Jovi, Enya, Roy Orbison, Pachabel, John Williams. (One of my favorites at a very young age was the William Tell Overture. I loved how it built to an exciting crescendo, and then gave one satisfying ending after another. I would run and jump and leap off the furniture to the galloping orchestra.) But I never owned a CD of my own until I went away to college. I was driving for the first time, and would change the radio station to whatever I liked as I drove.
What was becoming popular in those days, the mid-90s, was what was called Alternative music. It was the alternative, I guess, to the rest of popular rock music. My impression was that the radio stations were called alternative first, and the music they happened to play picked up the tag from them. I liked it because it was a little bit richer-- the melodies did more complex things, the lyrics were more thoughtful, the voices cracked with pain, as if the singers were just barely holding it together. (And it was coming from the left-- there's nothing like being dropped into a hyper-conservative place like BYU to make you realize that your own opinions are rather more liberal on things like feminism, environmentalism, and the roles of government.)
When I tried to share the music with my family, they were unimpressed. Where I heard suppressed anger and pain, they heard mostly whining and swearing and drugs. And I guess I liked that, too: it was transgressive, a little shocking.
Alanis Morissette was at the center of the genre. The songs from Jagged Little Pill-- "You Oughtta Know," "Hand in my Pocket," "Ironic," "You Learn"-- were all among the most popular. I liked them, but I don't know that I would have picked her as a particular favorite. And then came "Uninvited."
The song was written for the soundtrack of City of Angels. (a good romantic movie in its own right, if far less rich than the black-and-white European film Wings of Desire it was based on.) Although some of the lyrics make sense in the context of the movie, I didn't see it until it came to the dollar theater (where it had been edited, as was the custom in Provo) and by then I had already imagined what the song might be about-- a picture that fits the lyrics better than the movie does.
The song starts minimally, with four notes played over and over. Then Alanis's voice comes in, carefully controlled, precise, beautiful and cold. The words she uses-- "unfortunate slight," "worthy," "deliberate"-- they aren't the pop radio sound of "love me, baby, yeah, yeah." It's precisely the way a royal would speak. Whenever I hear this song, I imagine her sitting on a throne, a little like this, though surely wearing black instead of white:
It's capturing a single instant in time. A man has just entered the court, someone mysterious and handsome and powerful in his own right. We never see him-- he's the listener, addressed in second person throughout the song-- but we see her reaction to him. She's flattered by his fascination. He, like her, is a ruler, a shepherd meeting a shepherd. There's a mystery here, for both of them. She calls herself an uncharted territory, he's an uninvited stranger. What she's feeling is an a attraction to the dangerous unknown that he embodies, and she knows he feels the same about her.
But what kind of royal court could this be? There are electric guitars in the background. The singer, Alanis herself, is inescapably part of the modern city world. What I imagine is the urban fantasy of Charles DeLint, where hiding behind the everyday reality of life in the city, there are supernatural courts of powerful and secret people. 
The lyrics spell this all out, but it's backed up at the same time by an incredible synthesis of modern and classical styles. Everything about the music is calculated to produce a feeling of uncomfortable, building, dangerous excitement. The minor key, established in the first repeated measure, grows repeatedly richer and wilder. Strings come in at unexpected moments, bending the notes to a new, even more unsettling harmony. The stoic squirms. The instruments come in a few at a time, building and building, blending perfectly the electric guitar and the symphony in a wild dance, and then, suddenly-- back to the first four notes themselves, and her ever-so-carefully chosen words of dangerous politeness: "I don't think you unworthy / I need a moment to deliberate." Again, in a rush, it all comes back, building to an even more frenzied peak before ending with a single, dying guitar chord.

Alanis Morissette never again wrote anything similar. I've looked for other music like this; Orchestral Metal has the guitars and the violins, but ruins it by filling it with angry men yelling at me. The group Evanescence managed to capture the feeling, occasionally, but never manages to get it all in the same song, and inevitably goes to a repeated chorus, which "Uninvited" never stoops to. Part of the power of the song is its uniqueness, its sense of otherworldly origins.

Monday, April 6, 2015

word2vec, Babel-17, Galileo, Adamic, and the displacer beast from Adventure Time

I came across (in a book of esssays by Italo Calvino) the following passage from Galileo's Dialogue Concerning the Two Chief World Systems:

"I have a little book which is considerably shorter than Aristotle and Ovid, which contains all sciences, and which with just a little study can allow others to form a perfect idea of it. The book is the alphabet, and there is no doubt that the person who knows how to put together and juxtapose this or that vowel with those other consonants, will get the most accurate responses to to all doubts and he will derive lessons pertaining to all the sciences and the arts. In exactly the same way the painter can choose from different primary colours set separately on his palette and by juxtaposing a little of one colour with a little of another can depict men, plants, buildings, birds, fishes; in short, he can represent all visible objects even though there are no eyes, feathers, scales, leaves or stones on the palette. In fact it is essential that none of the things to be represented, or even any part of them, should actually be there amongst the colours, if one wants to use them to depict all manner of things, because if there were on the palette, say, feathers, these could only be used to depict birds or plumage."

This immediately reminded me of word2vec (which is on my mind constantly these days). You can think of word2vec as a bilingual dictionary. The other language is a strange one: every word has exactly 300 letters. The difference is that in that language, words which have similar spellings are similar in meaning. The remarkable thing is what an enormous amount of knowledge about the world is wrapped up in the spelling of these words. Just as one can guess at the meaning of tele-phone by the meanings of its Greek roots, or at the meaning of a Chinese word by the meaning of its characters, so to in this language the meaning of a word can be learned from the characters it is written with. The consonance, assonance, and rhyme between parts of the name, and the relationships between the letters, encode "approximate knowledge of many things."

There are two important differences, however. The first is that each of the letters, by itself, has an incomprehensible meaning. This is similar to what Galileo was saying about letters and colors of paint. If you have a pigment that is "feathers" you can only draw birds or fancy hats. But these letters let you express whatever you want, by not carrying a meaning by themselves, only by their juxtaposition.

The second is the sheer enormous amount of knowledge contained in the structure of the spellings. The capital of every country or state, the parts of machines, the attributes of movie characters, the celebration of holidays, all are contained in the spelling of the words. It resembles Babel-17 in that once you learn the true names of things, you know all the facts about those things. It is the language the world is written in. And yet at the same time it is profoundly dependent on our culture.

Wednesday, April 1, 2015

Sunday, March 15, 2015

Finding weighted sums of vectors

Suppose you have a vector that you want to represent as a weighted sum of other vectors. This happens to me all the time. For example, I might have a small part of an image (called a patch), and I want to have a compressed version of it, like when the image gets compressed by JPEG. In that case, the patch is represented as the sum of a bunch of simple patches that look like this:
If I have a simple vertical gradient in the patch, I could give the second basis patch in the first column a weight of 1, and all the others a weight of zero. A more complicated patch would need several of the basis patches to have weights between 0 and 1. But I would almost never need to use any patches except the ones in the upper left hand corner, unless the patch was from a picture of a checkerboard or something.

Another situation where I need to take a weighted sum of a bunch of vectors is in AI programs. Suppose you have a vector that represents an idea, like "childhood," and another vector that represents "old age." Then the vector for "adolesence" would be a sum of the two weighted more heavily toward childhood, and the vector for "adulthood" would be a sum of the two weighted more heavily towards old age.

A third time I needed this was in trying to estimate structure from motion-- trying to guess the shape of an object from the way points on the surface appeared as a camera moved around the object.

Another way of saying it is that I want to represent the vector in a new coordinate system-- a coordinate system whose axes are whatever vectors I choose. Anyway, it's a problem that's come up at least half a dozen times in my career.

If the number of independent vectors you want to sum up exactly matches the number of components in the result, then this problem can be solved by math you might have learned in high school Algebra II. You take all the vectors you want a weighted sum of (call them vec1, vec2, and vec3), and you stack them next to each other to make a matrix (at left.) then you put the goal vector on the right of the equation. The weights are the vector that makes the equation below true:







Weight1 gets applied to vertical vec1, weight2 gets applied to vec2, and so on. This is just a system of linear equations that needs to be solved, and you can do that by taking the inverse of the matrix, and multiplying that inverse by the goal, to get the weights (being careful about left and right multiplication how you do when multiplying by matrices).

The trouble is, you can only take the inverse of a square matrix. In real life, you usually have more or fewer vectors you want to sum than components in the goal vector. If you have too many then they're not going to be independent. If you have too few, the goal vector may not lie in the space spanned by the basis. In that case, you need to do the best you can: get weights so that the weighted sum is as close as possible to the goal vector, but not necessarily exactly equal to it.

Luckily, in 1920, E.H. Moore discovered the right way to do this. In 1955, Roger Penrose independently discovered the same solution, so they call it the "Moore-Penrose pseudoinverse." I don't know much about E.H. Moore, but Roger Penrose is a cool guy. He invented the Penrose aperiodic tiles (he was friends with M.C.Escher), he made up twistors which are the foundation of loop quantum gravity, and he wrote some interesting and controversial books about quantum mechanics in the brain.

I don't really know how the pseudoinverse works-- I learned how to write a program that would converge to the solution in one of my PhD classes, but I've forgotten. But it doesn't matter, you can just use it without knowing how it works. It's very fast in Matlab (it's called 'pinv'), and it gives the weights with no trouble. There's a trick you can do to get non-negative weights, if that's important for your problem (it's called 'lsqnonneg' in Matlab).

Wednesday, January 21, 2015

The Country wherein Art and Science have been Interchanged

In that country, artists play the role of scientists, and natural philosophy is purely the province of the artist. Instead of publishing papers on ways to represent the effect of light on snow in oil paints, each scientist in that country must discover it for himself, or in conversation with friends; and the results are judged largely on popularity among the fashionable, rather than through a rigorous process of review by scientific peers.
Conversely, the artists in that country do not explore their topic of interest (whether it be animals, or weather, or the workings of the mind) through performance and exhibition, but break down art into its simplest components, and publish dry, scholarly missives about some small part of what would more naturally be an artistic whole. Instead of admiring a world-view for its artistic integrity and daring composition, their works are judged solely on technical accuracy. The individual artist generally gains recognition only among other artists in similar fields, and most see their work as part of a much larger collaborative composition.
This has resulted in a strange state of affairs; for their novels are the composition of one author (or at most two) working alone, and each must perform the research needed to build a realistic world on his own. Thus the novels are small, pathetic things, but with a certain charm in their unified viewpoint. Whereas their physics is a vast monstrosity, full of the most carefully checked detail and explored in every ramification, and accurate to the highest degree; but it is a dry thing, and appreciated solely as a tool, rather than for any particular beauty.

Sunday, January 11, 2015

Why Kepler-442b is probably habitable

Last week NASA announced that eight more of the most promising Kepler planetary candidates had been confirmed. The most interesting of these is Kepler-442b. I'll call it 442b for short. It was previously known as KOI-4742.01. The KOI designation includes things that haven't been confirmed as a planet yet.

442b is the only planet in its system we've discovered, though there may be smaller planets or planets with a year longer than 3 years. We wouldn't have been able to detect those other planets in the system, because they haven't crossed their star from our viewpoint yet, and we've only been looking carefully at this star for the past few years. The 'b' designation means it's the first body in the system detected other than the star. The prevailing theory says that it is important for Earthlike planets to have a few gas giants in their system to sweep up asteroids, so that fewer will hit the planet and prevent life from developing, so we'll want to keep watching this star to see if we can see something like Jupiter for that system.

442b orbits an orange star. This is somewhere between a red dwarf star and a yellow star, like our sun. It means the star is smaller and dimmer than the sun. Kepler orbits closer to its star than Earth does to the Sun: its year is only 112.30 days long (this is one value we know very accurately.) This is close enough that the planet gets about two thirds of the amount of sunlight as Earth does. That still seems pretty bad-- Mars gets 44% as much sunlight as Earth does, and it is really cold-- but luckily, 442b is larger than the Earth. Its radius is a third larger than Earth's radius (another value we can measure directly.) Assuming a composition similar to Earth, it would have a mass about 2.3 times that of Earth, and it's surface gravity would be about 1.3 times that of Earth. More gravity means the planet can hold on to a thicker atmosphere, which means greenhouse effects increase the overall heat of the planet. There's a lot of uncertainty in the temperature, so it could be either too cold, too hot, or just right for humans. On the other hand, the poles would be colder and the equator warmer, just like on Earth, so it seems more likely than not there would be somewhere on the planet we could be comfortable. This is why I say 442b is the most interesting of the ones discovered in this batch: there is another planet (Kepler-438b) even closer in size to Earth, but it orbits much closer to its own star, with a year of just 30 days, and since it is larger than Earth and gets more sunlight than Earth, I would expect it to look more like Venus than like Earth. Also, with a 112 day year, you don't have the risk of tidal locking that you did with some of the earlier discovered 'habitable' exoplanets.

On larger worlds, the theory says oceans would tend to take longer to develop, though they would be deeper and last longer.

442b is 1300 light-years away.