Wednesday, December 25, 2013

A play

Going through some old documents I came across my first attempt at writing a play. Maybe a little embarrassing now, but I am afraid I will lose the document sooner or later. This is for the record. I remember that I couldn't settle on a name for the play, and the file that I found is called "ytbn" - short for "yet to be named". As far as I remember, it never was named.




Introduction:

The play is an incident in a society that dictatorially enforces conformance of deeds and ideas. This society is loosely fashioned after the society portrayed by George Orwell in his book, “1984”.



Characters:

The salesman (our protagonist)
The shopkeeper
Merry, assistant to the shopkeeper
Agents of the government



The curtains open to melancholy setting of a neighborhood. It is evening. Our protagonist, a salesman, walks on a street lined with shabby looking houses. He, apparently, is new to the neighborhood, since he walks slowly and allows his eyes to inspect every signboard that he notices. Shortly he comes near a lamp post and is momentarily shocked to see two men, dressed in black overcoats standing beneath it. Their surreptitious presence makes him pause, but with a voluntary effort he resumes his pace, to stop again after a few brisk strides. He has found what he was looking for. His eyes travel over the signboard of a shop. The shop is small, and almost looks as if it has been forcefully tucked into an incredibly narrow space between two houses by a superhuman cause. The sign reads, “The Curio Shop”. Without further deliberation the salesman walks in.

            The shop is dimly lit. In the prevailing semi-darkness it is difficult to see any merchandise that the shop might deal in. Presently a person appears and addresses the salesman.

New character/Shopkeeper: Good evening! I am the shopkeeper. How may I help you? (Smiles pleasantly)

Salesman: I am a salesman. I am looking for a few things (clears his throat) that I might find here – so I have been told.

Shopkeeper: (Pleasantly smiling) Yes, of course! We sell quite a few things here that are hard to come by otherwise.

He gently sways his hand in a gesture of welcome towards his left. The light adjusts to reveal an array of mantelpieces.

Shopkeeper: (Continuing, with unmistakable excitement in his voice) Mantelpieces like these, Sir, I assure you, you will find nowhere. We also have some exquisite furniture, and certain other things I would like to show you, should you have the leisure to look at them!

Salesman: (Shuffles his feet and looks uncomfortable) Er..yes. (Pauses) But this is not what I came here for.

Shopkeeper: (Narrowing his eyes, but keeping his smile intact) I am not sure what you are talking about. Perhaps, you would want to quote a reference?

Salesman: Frank.

Shopkeeper: (Pauses, but quite commendably still holds his smile) Ah, yes. This way please.

The shopkeeper leads the salesman to a wall in an inner room. Placing his palms together on the wall, he gently slides them towards himself. A faint click… a hidden door!
The door opens to reveal another badly lit room, the contents of which are not immediately visible.

Shopkeeper: Before we enter ….(looks about himself)…Merry! Merry!

Another man appears, He is unremarkable in any other way but for the calmly morose expression he wears.

Shopkeeper: (To the salesman) This is Merry, my assistant.

Merry looks at the guest but doesn’t attempt a smile. It is almost as if Merry and the shopkeeper complement each other as far as their expressions go. The shopkeeper is a perfect salesman with a ready smile at his disposal. He seems almost incapable of any other expression, something that can be said equally well for Merry, who, however, is a picture of gloom. They are like two poles of emotions in a balanced conversation, embodied apart.

Shopkeeper: Merry would watch the shop while we are inside. I apologize for my earlier behavior. You are obviously aware of how things stand today.


The salesman, the shopkeeper and Merry stop mid-air in their actions, as another part of the stage lights up to depict their thoughts at the moment. Here we see a bonfire of books and paintings, tended by men wearing black overcoats. Nearby, a person, presumably the owner of the property that feeds the spiteful fire, is being forcefully dragged away by more men in black overcoats. He resists, but his face is painfully calm, proclaiming that this was inevitable, and he knew that such a day must arrive. This distressing sight stays for a moment and then vanishes, with the portion of the stage returning to darkness, as our three characters become animate again.

The shopkeeper and salesman walk into the newly revealed room while Merry stays outside. Inside the room, we now see shelves lined with transparent masks.

Shopkeeper: (Smiling) These masks, as you would know, have no features, only expressions. When you wear them, they take on the features of the face underneath, but the expression is theirs. A happy mask makes you look happy; a sad mask makes you look sad. Always.

The salesman reaches inside his pocket to draw out his purse to pay the shopkeeper.

Shopkeeper: (Smiling) Which one will it be then?

Salesman: The one that smiles, of course.

Taking down a mask from the shelf, the shopkeeper wraps it in a piece of brown paper.

Shopkeeper: Here it is. Please hide it well when you carry it outside. Our shop is already being watched.

The salesman and the shopkeeper leave the inner room and the sliding door is pushed back into place. Merry, with his unchanging morose look, who has been waiting at the other side, disappears as soon as they return.

The salesman carefully tucks the wrapped parcel into his jacket and makes to leave the shop.

Salesman: Thank you!

Shopkeeper: You are welcome! But be very discreet about this little affair.

Smiling a knowing smile, the salesman walks out. He makes brisk pace on his way back. As he nears the lamp post, he spots the two men in black overcoats still present. Distracted, he tries to take a quick step, and trips and falls. The brown package is thrown away from his person due to the impact. The wrapping was not well done, and a part of the mask is now clearly visible in the package, which is now lying on the ground.

The men become suddenly alert, and lose no time to run to the shop after they notice the now ill-guised contents of the package. The salesman is paralyzed with fear, and not knowing how to react to this new development, watches panic stricken in the direction of the shop.

The men disappear into the shop. Awhile later Merry and the shopkeeper are brutally dragged outside into the street. As they shout, scream and their limbs flail wildly in the air, the salesman notices that the shopkeeper can’t help but still smile pleasantly. Merry, too, like a vivid contradiction to the world around him, to the reaction of his body and his very name, wears a mask of calm moroseness.

CURTAIN

Sunday, April 7, 2013

Thoughts on Online Learning

When online learning became a reality for me with MIT OpenCourseware, I was excited. I could watch Gilbert Strang teach Linear Algebra for free and learn at my pace. So when Coursera and Udacity were launched I was as happy as the next guy, if not more. I work with Machine Learning at my job and it is extremely valuable to me that I can watch related videos online, for free, with the content taught by some of the most prominent researchers/practitioners in their respective areas.

But it doesn't seem to have worked out very well for me. And apparently not for a lot of other people either. Personally, I am back to reading books. With a year of Coursera/Udacity behind us, I am seeing articles, like these, discussing shortfalls. In this post, I want to discuss where these fell short for me.

To be clear this is an extremely subjective article discussing things from my point of view. One that is not called "What's wrong with online learning?".

What I find missing

My first two online courses were Linear Algebra by Gilbert Strang offered by MIT Open Courseware and Machine Learning taught by Andrew Ng offered by Stanford Engineering Everywhere.When I had initially started going through the material, I wasn't doing much beyond watching the lectures and occasionally scribbling notes. Although the courses filled me with an immediate sense of achievement, I realized that my ability to recall finer details later was essentially broken. In most cases, when coming across a concept elsewhere, I could relate to it at a high level - but to dwell on the workings was difficult, and I often had to go back to the videos for a quick revision.

At this point, other problems would crop up - videos are not text books that you remember the layouts of. That makes skimming and visually searching difficult. They don't have indexes that can facilitate quick look-ups. I would typically narrow down to a specific couple of videos (one - if lucky) and then rummage about with the playbar till I found what I was looking for. Not  to mention I needed a computer and my video lectures around for that. Thus, not only was I unable to recall specifics, but digging them out was no walk in the park either.

To fix this, I re-visited the lectures and prepared extensive notes this time. That worked out amazingly well for me - I remembered most of the stuff, and had a ready reference to consult (my notes).


Fig 1. Notes from Machine Learning

But these came at the cost of a huge amount of learning time - if a particular video lecture was an hour long, listening to it and making notes seemed to take roughly twice that time, assuming I took detailed notes, and not merely wrote down what I heard/saw but phrased it in my own words.

Given that I was never much of a note-taker in class, and still did well on most of my courses, I had to wonder - why is it different now? Here are a few things I missed in my online learning experience:
  1. Active participation in the learning - in classes, I could ask questions. Equally important - others could ask questions. All during the class. The opportunity to ask questions worked to my benefit in two significant ways:

    • It kept me engaged. At some level, it felt as if the class was collectively and organically working towards discovering something

    • It prevented technical debt. Usually that term is used in the context of software development, but I feel it is equally applicable here. One shoe doesn't fit all - so if the material prepared by the lecturer falls short in satisfying a student he can immediately ask a question to satisfy his information need. With video lectures, I had to make a note to Google up something later. You could pause the video and do that instantly. Or, you could let these pile up and attend to them later. Either way, that wasn't the best of experiences for me for subjects I really cared about.
  2. Learning in a class for the want of a better term, is an immersive experience. This helps recall and motivation. You remember more than just the content from the class - you remember people, places, a comment that made you laugh, etc. Sometimes, these help recall stuff better. You also see real people sitting next to you trying to be good at the same thing as you. If you want to discuss a specific concept with them, it is easier verbally than posting on a forum. There is collective motivation to learn and communication with peers is easy.
  3. If you want to go back to revising something you can refer to your notes, the lecturer's notes or the textbook the class is following. With video lectures this is tough.
In a nutshell, for online courses, I don't think the content registers too well because they don't do great on the first couple of fronts. And what doesn't register, should at least be easily searchable -  unfortunately, that doesn't happen either.

I mentioned I have moved back to text books. Why am I learning better with them? With regards to the first two factors I think textbooks actually do worse than online learning. But they do way better when it comes to ease of revisiting stuff - and that ease aids reinforcing of material which sort of makes up, over a period of time, for the relatively lacking engagement.

It hit me when I started taking the course on Probabilistic Graphical Models by Daphne Koller. The lectures were detailed -I loved them- but the need for taking detailed notes increased too. Given my full-time job it was becoming difficult - I was not sure how long I could keep up.


Fig 2. Notes from Probabilistic Graphical Models

One weekend I ended up with a sprained neck trying to take notes for a bunch of lectures.  I gave up, re-enrolled when the course was offered the next time, only to again drop out for similar reasons. The gamification (deadlines) made me feel stupid and was demotivating. I realized that this wasn't sustainable for me and went back to books.

To sum up the comparison, textbooks provide me with a medium I can easily revisit, and the time I am not spending creating this easily searcheable medium - which I would have to for video lectures i.e. take extensive notes - makes up for the other benefits video lectures have to offer.

Possible solutions

To be frank, I don't know what changes would make online courses better for me. It's hard to know without actually trying. Personally, I should probably focus on only one course at a time and accept the fact that it is going to take me much more than the stipulated time to finish it.

However, if I were to take guesses as to what might make courses better, this would be my list:
  1. Make lectures more interactive - this would promote engagement. Interaction in courses exist - the operative word is "more". Better engagement would help better recall and drive down the need for extensive note taking. Note that this does not completely do away with the need for taking notes - but only eliminates the need to do it in painstakingly copious amounts.

    Interaction is one way to promote engagement. There might be others too. Perhaps, something on the lines of what the Head First guys did for programming? They made reading programming books as easy as reading story books. Is there a way to make watching video lectures as effortless as watching a movie? Or, playing a game - like this experiment from UCSD.
  2. Make them searchable - somehow. Find a way so I can revisit the course for specific topics with ease. Transcribe the speech of the lecturer and index the video timeline with words from the transcription if that's what it takes!
  3. I like how Erik Demaine prepares his courses.

    Fig 3. Geometric Folding Algorithms by Erik Demaine

    Fig 3. is from his course on Geometric Folding Algorithms. There is a lecture video on the page, there is a frame with handwritten notes in it (shown in a black box) and there is another frame with slides in it (shown in a red box). The video, the notes and the slides are synchronized: when Erik moves ahead with  his lecture, the slides and notes change pages too.

    This helps the learner associate textual content - notes/slides - that can be searched (probably easier after printing) with the actual lectures. This is a clever way of maintaining the engagement videos give us, and making the content easy to revisit later without actually revisiting the video. All depends on how strong you can make the association between the text content and the video in the presentation.

    InfoQ and videolectures.net do this to some extent too.

Wednesday, November 9, 2011

The Best Card Trick


... is the title of an article [PDF] from the Mathematical Intelligencer I recently came across that, well, discusses a namesake card trick. As  it turned out, the somewhat presumptuous title notwithstanding, the trick happens to be pretty interesting. Not to mention it gives me enough material to to gab about and break out of my posting hiatus (before slipping into another :) ). So, here we go ...


A bit of history

The original article offers close to 1.5 pages of history if you are interested - consider this section a "tl;dr"-ed version.

  • The trick appeared in the book Math Miracles by Wallace Lee, where it is credited to William Fitch Cheney Jr., a.k.a. "Fitch".
  • The article is by Michael Kleber.

Here's where I would have ideally ended this section (a bit of history: check) but Fitch having been the interesting character that he had been, it would be unfair if I didn't mention the following facts about him before we move on:

  1. If a name like "Fitch" inspires the image  of an ordinary performer of card tricks, or worse still, a street magician, you couldn't be more wrong - Fitch was awarded the first PhD in mathematics from MIT in 1927.

  2. As a teacher, Fitch seems to have been unusually entertaining:

  3. "... he enjoyed introducing magic effects into the classroom, both to illustrate points and to assure his students' attentiveness. He also trained himself to be ambidextrous (although naturally left-handed), and amazed his classes with his ability to write equations simultaneously with both hands, meeting in the center at the "equals" sign."
      --- from a description of Fitch by his son, Bill Cheney

Trick, and a mathematical treat

To appreciate how the trick works under the hood, lets start by looking at it from the point of view of the audience. If you were at the receiving end of the trick this is what you would see:

(1) The magician holds out a normal deck of 52 cards to you, and asks you to pick 5 cards.

(2) You do so and hand them over to his assistant.

Say, this is what you pick:


(3) Of the 5 cards handed over to her, she hands 4 of them to the magician. Say, these:



(4) He looks at the 4 cards handed to him, and with < insert favorite dramatic gesture here > announces the 5th card you had selected.




Take a while to think about what happened here. Assuming a normal, well-shuffled deck and no underhand techniques, the objective of the magician seems to be to look at 4 cards, handed to him by his assistant, and infer the 5th. With absolutely no prior knowledge of the selection on part of the magician (in other tricks this is typically arranged for by using a deck with more cards of one kind than another, or stacking it up in some particular way etc), how exactly is the assistant to indicate the rank and suit of the 5th card using the 4 cards she hands over?

What messages can you pass with 4 cards ?

A possible way seems to be arranging 4 cards in a way that identifies the 5th card i.e. you could use the ordering of 4 cards to encode the suit and rank of the 5th card.

But there is a catch here - 4 cards can be arranged in 4! = 24 different ways, whereas the 5th card could be any one of the remaining 52 - 4 = 48 cards. Apparently we do not have enough arrangements of 4 cards to indicate the 5th card. One card more, and we would have been good to go - but, the technique doesn't seem workable as-is.

In essence, the trick is not a sleight-of-hand-ish trick - it boils down to compressing and conveying information. Fitch being a mathematician probably has something to do with this.

So,which 4 cards does the assistant hand over to the magician? And how do these indicate the 5th card?


The workings

We saw how we fall short when we try to use orderings for our purpose; this is where the trick gets interesting. Instead of abandoning the approach completely, it looks deeper at the kind of objects we are dealing with. Each card is marked with a suit and a rank - can these attributes help us in squeezing in more information? Apparently, yes:
  1. Since there are just 4 suits, but you have picked 5 cards, there are at least 2 cards of the same suit in your selection (Hello, pigeonhole principle!). In the above example these are 3 ♠ and 10 ♠ . As per a convention decided upon by the assistant and the magician, the assistant holds back one of the cards with a repeated suit, and in the arrangement of cards he hands to the magician, he positions the other card of the suit as the first card. Looking at the first card, the magician now only needs to guess the rank of the unseen card - the suit is same as that of the first one.

    Look at the cards in step 3 above; 10 ♠ is the first card handed over. The magician knows that the 5th card is also a spade.

    But with the first card used to reveal just the suit, we have only 3 cards left to guess the rank of the 5th card. Which can take on 13 values. But 3 cards can be arranged in only 3! = 6 ways.

    Ouch. Again.

  2. Since our strategy is already piggybacking on the repeating of suits, it's worth asking, among the cards with the repeated suit, is there a good way to pick the card the assistant would be sliding into the first position?

    In the above example, this is equivalent to asking, between 3 ♠ and 10 ♠, which card should be put in the first position?

    Is there an optimal choice here? Optimal in a way that helps us to work around he limitation we encountered above i.e. can choosing the 1st card wisely, lets us use just 3 cards to indicate the rank of the 5th card ?

    Turns out, the answer is yes. Here's a short, math-savvy hint: modular arithmetic.

    In simple words, here, this means that we do not directly indicate the rank of the 5th card, but we indicate what number you should add to the rank of the 1st card to obtain the rank of the 5th card. Except that we agree to a way of handling the addition when it goes beyond 13 - in such cases, we simply start counting at 1 again.

    This can be easily understood by imagining the ranks to be laid out in a circle. Adding x to a number y here is equivalent to going x steps around the circle, clockwise, starting from y.



    So, 10+5 is 2. 13 + 1 is 1. And, of course, 2 + 3 is 5.

    How does this help in working around our earlier limitation? Consider the shorter distance between any 2 points on the circle - its
    never greater than 5. This means that of 2 points in this circle, I could always pick a point, so that you wouldn't need to add a number more than 6 to reach the other point. This is important since the remaining 3 cards - the ones at positions 2nd, 3rd and 4th - can be arranged in 6 different ways.
    Take the points 3 and 10 for example (the ranks of our cards with the suit ♠ ). If you were given 3, you would need to add 7 to get to the point 10. But if you were given the point 10, you would need to add 6 to get to the point 3. This is why the assistant passes 10 ♠ to the magician in our example, and not 3 ♠ (and arranges the other cards to indicate the number - 6 - to be added; we'll get to the arrangement in a while)
    Thus, it turns out that if we pick right the card of the repeated suit to be given to the magician, the ordering of 3 cards is sufficient to indicate the rank of the unseen card. This completes our strategy.

Here, to implement point 2, one could follow any system to encode numbers by orderings, as long as the magician and his assistant have agreed upon it. A simple way could be to use the ordering of suits and ranks used in the game of bridge:
  1. Ordering of suits, highest to lowest: ♠, ♥, ♦, ♣

  2. Within a suit, ordering of ranks, highest to lowest: Ace (A), King (K), Queen (Q), Joker (J), 10, 9, 8, 7, 6, 5, 4, 3, 2.
For our cards in positions 2nd to 4th ( 8 ♥, K ♦, A ♣), this implies the following encoding for all possible arrangements (assuming a "lower" ordering corresponds to a lower number):

  • A ♣, K ♦, 8 ♥ → 1

  • A ♣, 8 ♥, K ♦ → 2

  • K ♦, A ♣, 8 ♥ → 3

  • K ♦, 8 ♥, A ♣ → 4

  • 8 ♥, A ♣, K ♦ → 5

  • 8 ♥, K ♦, A ♣ → 6
Thus, looking at the ordering of these 3 cards, our magician adds "6" to the rank of the first card, which is 10. This tells him that the 5th card has a rank 3 (remember he already knows that the suit is a ♠).


In summary

The following image tries to sum up the reasoning of the magician:


You can blame Google for the crummy resizing.


Stage advice ...

Some practical advice from the article if you are indeed planning on performing the trick:

  1. If trying to determine what number the ordering of the 2nd, 3rd and 4th cards corresponds to in the manner discussed, seems a little clumsy, the author of the article suggests his own variation.

    "... place the smallest card in the left/middle/right position to encode 12/34/56 respectively, placing medium before or after large to indicate the first or second number in each pair"

    As an example, the ordering "A ♣, 8 ♥, K ♦" would imply a rank of 2, since the smallest card, A ♣, is in the first position (so this is either rank 1 or 2) and the medium card, K ♦, follows the large card, 8 ♥ (which makes it rank 2).

  2. This one, straight from Fitch. If you are repeating the trick to an audience, say for more than a few times, there is the risk that someone would notice that one of the cards with a repeated suit is always in the first position. In such a case, place the card that indicates the suit in the (i mod 4)th position for the ith performance (we assume position "0" indicates the 4th position).

    Thus, for the 1st performance this card is in position 1, for the 2nd performance this is in position 2, for the 7th performance, assuming your audience is still around and awake, this goes in at position 3 (since, 7 mod 4 = 3).
Generalization

If you go through the various steps above, the ideas involved seem to just about fit in: simple ordering seems deficient? - repeated suit to the rescue; 3 cards are insufficient to indicate a rank? - modular arithmetic alert.

happy-go-lucky patchwork of clever ideas as it were...

... which, well, really is fair game. However, the key contribution of the article is that it convinces you this is not all that there is to it: it analyzes these seemingly ad-hoc steps rigorously and suggests extensions of the trick. Unfortunately, this is not something I will go into, in this post, since I want to keep it fairly non-technical. For those who are interested, going through the original article is strongly recommended. I intend to follow-up this post with another one focused only on the generalizations, at a later point in time.



Friday, November 6, 2009

The Perfect Murder




A murder mystery is solved when the detective notices a circumstance that stands out from the rest. If circumstances were cocktail sticks, this is the perfect murder; given their flawless conformance - no one cocktail stick stands out! - our detective is at a loss to discover the culprit.


Source Of Image: alastairlevy.net

Saturday, September 19, 2009

Boom mike in FRIENDS

From the 12th episode of Season 8 - "The One Where Joey Dates Rachel". Notice how the boom mike moves across the wall clock above the whiteboard.




( I must really, really, look for better things to post :) )

Thursday, September 17, 2009

Eccentricities

(1) Don’t think laptops are a good idea for me : I am more of a pen (rather pencil – see (2)) and paper person, who likes to write out ideas on paper first. I tend to code only when I am pretty sure of the structure of my code. I don't use my editors as my scratchpad (python/ruby are changing that a little now... Ah! I almost sense you asking whether I was living under a rock until now? Unfortunately, yes - under one called Java). And when you know what you are going to write it usually doesn't take a lot of time -for which I can arrange for being in front of my desktop.

(2) Pencils: Use pencils to take notes, write exams with pencils. Maybe I like the sound graphite makes when it moves on paper. Or the feel of it. Maybe since I hold my writing instruments vertically pens tend to run out of ink temporarily; or tear paper when I try to write fast. Maybe I hate the many scratches I would have to make with a pen when working on a rough idea - erasing out parts to replace them with better ones is so much more convenient. Maybe I hate turning pages (because the scratches are now an ugly collective clutter) when working on an idea - it affects my flow.

(3) Math: Like math. Maybe the world is not such a deterministic place as it is when I am staring at a math problem in the small universe of a notebook page in front of me. I like the way it challenges me. Maybe I like the way it makes me feel about the world : despite its superficial lack of structure problems can be broken into predictable smaller sub-problems.

(4) Rains: I just get lost when it rains.

Friday, January 23, 2009

The 'inverted' Apple

This first picture is a still from the movie "What Women Want", which I took while watching it. The second picture, is from Google Image search. Note how Apple has changed the orientation of its logo. Or was it just one bad bunch of Apples?