Sunday, November 8, 2009

The Unique Skill of Understanding a Foreign Language

Daniel Tammet said
"It's one thing to learn a language it, to speak it, to produce it, to be able to talk with somebody. Comprehension, actually listening to a language and understanding it, that's something else because it takes time for the ear to get used to the totally different sounds"

Additionally, written language and spoken are often quite different. The vocabulary is different, and grammar rules are not respected. At least in English and Portuguese there are a tremendous number of sounds that are dropped when compared with written language. Ultimately, what got me over the hump was to recognize groups of sounds/words that occur together frequently and hear them as a single word.

For example, a Brazilian telling a story will start many sentences with "D-F-L". I finally asked someone what that mysterious word was. Turns out they are saying "Dai, eu falei" or "Dai, ele(a) falou" ("And then I said" or "And then (s)he said") The actual phrase has 5 syllables, while the compressed one is nearly 1. You wouldn't come across this phrase in any book and maybe not even on TV. It is something unique to natural, unplanned conversation.

So imagine that the spoken and written language are two different languages altogether. What are the implications? It means that you need to build up a vocabulary of sound groups. These will form the "vocabulary" of the spoken language. This is a hard task because it is usually not written down anywhere. But if you have access to native speakers, you can ask them questions just as I did. And I found that having even a small vocabulary of such "sound groups" goes a long way.

There are at least two benefits to thinking about written vs. spoken language this way. First, you will have less and less of a problem with people speaking too fast because you won't be translating from spoken language to written language (and then possibly back into your own language). You will hear a phrase and treat it as a single idea.

Second, you won't feel so bad that your comprehension skills are low because you'll realize that the task is actually quite difficult--you are learning 2 languages, not just one!

Thursday, November 5, 2009

SVD, PCA, Eigenvectors and all that

Principal Component Analysis (PCA) provides matrices E,L given a symmetric real matrix C such that CE=EL. The columns of E are the eigenvectors and L is a diagonal matrix with eigenvalues on the diagonal.

Singular Value Decompsition (SVD) decomposes an arbitrary real matrix A as A=USV' where U'U=1, V'V=1 and S nonzero only on the diagonal. Thus A'A=V(S^2)V' so that (A'A)V=V(S^2). Comparing this with CE = EL from PCA shows that V holds the eigenvectors and S^2 are the eigenvalues of A'A. To summarize,

SVD(A) gives eigenvectors of A'A. (1)

In applications we often start with a data matrix A where feature vectors are the rows of A. For example, suppose we have a data matrix where each row is an RGB triple that records color samples of skin. We might be interested in extracting a single direction that best approximates this distribution. To do this we first center the data (subtract the mean RGB triple from all rows of A) and find the principal eigenvector of the distribution. Computationally, we let B=[centered version of A], then SVD(B) yields the eigenvectors of B'B. A numerical example is given in [1].

What happens if we start with a symmetric matrix C instead of a data matrix A? For example, each entry c(i,j) could be a direct measurement of similarity between item i and item j as opposed to being computed as a bunch of products as in C = B'B above. Can we still use SVD to get eigenvectors of C? Because according to (1), SVD(C) gives the eigenvectors of C'C, not C.

We can. SVD(C) gives us the eigendecomposition C'C=VSV'. But C symmetric means C'C=C^2 and so C^2=VSV'. Then we can apply the power trick: A^k=Q(D^k)inv(Q) letting k=1/2 so that C=V(S^(1/2))V'.

SVD(C) gives eigenvectors of C when C is symmetric (2)

Note: It is often said that U and V are "the same by symmetry" when C is symmetric. Precisely how? For example, let C = [0 1; 1 0]. Then SVD yields U=S=1 and V=C. In particular, U is NOT equal to V. (This also shows the fallacy of reasoning that USV'=C=C'=VSU' implies that U=V). However, it IS the case that U and V are the same up to a column permutation. Why? SVD(C) gives the eigenvectors of C'C in the columns of V. SVD(C') gives the eigenvectors of CC' in the columns of U. When C'=C it follows that C'C = CC' so that U and V both "hold" the same eigenvectors, up to column permutation.


[1] GNU Octave example

octave:32> a = rand(5,3);
octave:33> b = a - repmat(mean(a),5,1);
octave:34> c = b' * b;
octave:35> [eigen, lambda] = eig(c)
eigen =

0.55689 0.59340 0.58116
0.56566 -0.78331 0.25778
-0.60820 -0.18518 0.77189

lambda =

0.19666 0.00000 0.00000
0.00000 0.22855 0.00000
0.00000 0.00000 0.74406

octave:36> [u,s,v] = svd(b);
octave:37> v
v =

-0.58116 0.59340 -0.55689
-0.25778 -0.78331 -0.56566
-0.77189 -0.18518 0.60820

octave:38> diag(s) .* diag(s)
ans =

0.74406
0.22855
0.19666

Friday, October 16, 2009

PG&E Dishwasher Rebate HOWTO




2. Fill out page 3. The tricky parts are:

Section 1
- PG&E Account Number is on your bill at the top left
- PG&E Electric Service ID is on the 2nd page at the top just under "Electric Account Detail"

Section 4
- Service ID # is the same as in section 1
- Product Code : "B35" or "B20". See page 1 of the pdf. They are listed in blue.
- Manufacturer: see dishwasher list
- Model #: see dishwasher list
- Unit Measure: "dishwasher"

3. Print and sign. Send in together with:

A. Retailer/Contractor name, address, and phone number
B. Itemized listing of each product including quantity, product description, manufacturer, model number, or other identifying information, i.e., SKU # as appropriate
C. Purchase price per product
D. Date “Paid in Full” or payment terms, such as “Charge” or “Net 30”
E. Product installation date

Tuesday, August 4, 2009

Bye Bye Yelp

I'm sad. I've decided to pull the plug on Yelp, a website that I really love. Why?

Well, the evidence of extortion is just too big to be ignored. It's not hard to find. I just searched for [yelp extortion] and turned up about 50,000 articles. Now accusations are not the same as being guilty for sure. So here is why I believe it.

1. The fact that so many people's stories are similar. These are people who are not in contact with each--how is it that they all have very similar experiences with Yelp management? It is hard for only 2 criminals to agree on a story to tell, much less hundreds of people.

2. Much more damning is my personal experience with Yelp. One of my reviews does not show up unless I'm logged in. (Evidently, they are smart enough to not filter out your review when they know you are looking.) When it was 5 stars I could see it, but when I updated it to 3 stars, it magically got dropped from the list of reviews! FISHY. And others have experienced the same.

So I'm pulling the plug, and deleting my account. Who knows if yelp will honor my wishes and actually delete my reviews?!

P.S. For those of you who think "Well, it doesn't affect me so I'll keep using yelp" consider this: how many restaurants will you waste your money on because the ratings were manipulated?

Friday, June 26, 2009

Get out of town

Sometimes I want a quick getaway, but don't have a particular destination in mind. Wouldn't it be great to say: "find all flights leaving SFO (or nearby) for under $400". Kayak now has this, but it is hidden away in "Buzz"--who picked that name?!!!

http://www.kayak.com/buzz

Sunday, June 7, 2009

Craigslist Scammer!

I'd always read about scammers on craigslist, but today was the first time I actually got hit up by one. Here it is, for your viewing pleasure:

From: peterchris002 chris (peterchris002@gmail.com)
Date: Sat, Jun 6, 2009 at 10:30 PM

Thank you very much for your swift response and for telling me the Item is still available.I want to let you know that i'm a deaf man and i am satisfied with the conditions has you have stated in the craigslist.

I have a schedule already,for i need to attend an important seminar in Hawai so i wont be able to come to check it at your place.Since i am ok with the condition,i will be sending you a certified check that will cover the amount of the Item and the moving funds.You are to take your money for the item from the check after cleared in your bank within 2-3 days and have the rest sent to the mover via western union money transfer or money gram.For your inconvenience,i will add $50 with the payment to be your running around fee.I'm always a busy person and i will not like to miss this item.The information of the mover will be sent to you after the check is received and he will be at your location for the pick up with a signed note explaining that he will be assuming responsibility for the item on my behalf.

Kindly get back to me with the following information for issuing of
the payment........

NAME:
ADDRESS :
CITY:
ZIP CODE:
STATE:
PHONE NUMBER:

Thank you

Thursday, June 4, 2009

Fixing broken space completion on Emacs 22.x

Solution thanks to Karsten Lang:

Joseph Brenner writes:
> I see that space-bar completion on filename entry is essentially
> broken in gnu emacs 22, because they wanted to give you the
> capability to type spaces into a file name. I don't want that
> capability -- I'm glad that emacs can understand filenames with
> spaces, and sometimes I need to select them via dired, but I
> personally never create files named like this.

> So: what do I need to munge in order to get the old space-bar
> completion functionality back?

klang was good enough to email me his solution (which I'm passing on with his permission):
(if (boundp 'minibuffer-local-filename-completion-map)
(progn
(define-key minibuffer-local-filename-completion-map " "
'minibuffer-complete-word)
(define-key minibuffer-local-must-match-filename-map " "
'minibuffer-complete-word)
)
)

Saturday, April 18, 2009

James Nourse's Rubik's Cube Solution

I have a 2 year old nephew that likes to mess up my Rubik's cube. I have no desire to learn optimized solutions; I just need to remember the solution I learned waaaay back in 1981--the one by James G. Nourse. This blog post has a simplified version:


It is hard to find his solution online and I don't want to keep Googling it everytime!

Thursday, April 9, 2009

Shared Documents -- what is it?

Came across this post for how to remove that annoying "Shared Documents" folder. More importantly, it explains that the folder is just a folder: C:\Documents and Settings\All Users\Shared Documents. So this is a real folder--not a metaphor for changing the sharing status of files put in there--so if you delete files from there they are really gone!

Instructions for how to remove this folder can be found by searching for (in quotes) "Have you ever wondered what is the “Shared Documents” folder doing in My Computer?" on your favorite internet search engine.

Saturday, March 28, 2009

The Fast 50% diet

Here are the main features of the diet:
  • Eat whatever you normally do
  • Save time and money
  • No exercise necessary
  • Super simple--no thinking required!
So what is it? Well, there are 2 parts. The first part is the "50%" part:

Eat half of what you normally would.

This means that you have to estimate what you would normally eat and only eat half of that. So if you go to a place that has ridiculously large portions, you might eat only 1/4 of the meal, because normally you would eat half.

You save money because food goes twice as far. You save money because you can eat the other half as leftovers. You save time because it doesn't take long to eat half as much!

So can you eat chocolate all day? Sure. If you normally eat 20 pieces of chocolate for dessert, just eat 10. As long as you do exactly what you normally would but eat only half, you guarantee that you'll be taking in only 50% of your usual calories. That should be enough of a reduction to get anyone down into the weight-losing mode.

You might think that dieting like this would leave you feeling hungry all the time. Normally, that would probably be the case, and that is why you need part 2, the "Fast" part:

Fast once a month to reset your appetite.

Years ago I noticed that fasting had an unexpected effect: right after fasting I would feel full sooner than normal. You'd think you'd be famished after breaking a fast, but if you eat slowly you'll notice that you get that full feeling much sooner than normal. Respect that feeling and stop after 50%.

For me, about 24 hours taking in only water or juice works. The point of the fast is not to skip calories, but to reset your appetite. As a practical matter I find it easiest to fast on a day when I'm doing light chores or shopping--something that keeps me active but is not strenuous.

Historically, fasting is associated with spirituality. And I think it helps your body and mind to get back into balance. As someone who loves eat, fasting helps me to keep food in the proper perspective.

Sunday, March 22, 2009

Me vs. The Environment


Most decisions involve a tradeoff between two factors that are in opposition. Saving money vs. saving time. Inexpensiveness vs. quality. Doing some quickly vs. doing something correctly.

The solution always involves knowing how important one factor is compared to the other. This differs from person to person and changes over one's lifetime. For example, kids choose saving money over saving time, but adults will hire help when time is scarce and money is plentiful.

So why is this reasoning rarely applied to environmentalism? In most cases there is a tradeoff of time/money/pleasure for saving the environment. Saving water vs. clean hotel towels. Reducing carbon footprint vs. international vacations. Recycling vs. saving time.* The list is endless. These issues are rarely presented as tradeoffs. Why not?

Environmentalism shouldn't be dogma. It should explain the benefits and the costs of working to preserve the environment, so that each person can make an informed decision.

* Of course it is possible to do things more efficiently so that personal loss of time/money/pleasure in negligible. But after you've squeezed all the wasteful inefficiency out, you eventually have to face a choice between personal time/money/pleasure and further perserving environment.

Thursday, March 19, 2009

Upload local Thunderbird email to Gmail

I had almost 30,000 old emails in Thunderbird dating back to 1996. Now that I've been completely converted to The Way Of Gmail, I want all my mail there. I figured it would be a piece of cake seeing as how Thunderbird was the geek email client of choice and that mbox is a very standard mailbox format. Wow, was I wrong. Here's what I tried:

1. imapsync. Only does imap-to-imap transfers.

2. Ryan Grove's ruby script. Doesn't work for Thunderbird mailboxes. I asked, and the response was "This script can’t read Thunderbird mailboxes. It should be possible to write a script that can read them (I believe Thunderbird uses an Mbox-like format), but I don’t plan to do it." He launched "Larch" in the last couple of days which does imap-to-imap transfers; seems like that could be very useful oneday.

3. Scott Yang's python script. Works for maildir mailbox format, not Thunderbird. I asked, and the response was "I do not know whether it works with Thunderbird mailboxes, however I do not think it would be too hard coding a solution for it. Working on Windows might take a bit of effort. Basically it’s not tested :)"

4. Google Email Uploader. Only works with Google Apps Gmail accounts, i.e. not normal foo@gmail.com accounts.

5. Google Email Uploader + foo@bar.com + forwarding. I happen to own my own domain--let's call it bar.com and a Google Apps site for that domain. That means I can have people send mail to me at foo@bar.com and it goes to my Google Apps Gmail account. I only use the Google Apps account to forward my mail to my normal gmail account foo@gmail.com. So I simply used Google Email Uploaded to push the mail to foo@bar.com and from there it got forwarded to my normal gmail account. WRONG. Forwarding caused the dates to get set to the current day, not the original day.

6. Manual IMAP push. At this point I got a little discouraged and decided to do things manually: setup gmail to provide IMAP access, then drag and drop my emails up to gmail in Thunderbird. This turns out to work, but it is Painful if you have a lot of emails. The transfers often fail, so you have to do them in small groups. Even worse, there seems to be a rate limit on uploading so eventually gmail will lock you out of IMAP for a period of time!

7. Google Email Uploader + foo@bar.com + pop3. This actually worked. What I did was instead of using forwarding, I enabled pop access on foo@bar.com. Then in foo@gmail.com I added foo@bar.com to the "Get mail from other accounts". SUCCESS. A couple of points:

- I don't think you need to buy your own domain to use Google Apps which is necessary to use Google Email Uploader. If that is true, this is a no cost solution. If someone can verify this and post a comment it would be great.
- Some of my emails get munged together. I'm not sure who is at fault: Google Email Uploader, foo@bar.com or foo@gmail.com.


Tuesday, March 10, 2009

Transitioning from Perl to Python

I'm excited.  I'm taking a Python class tomorrow.  At the same time, I'm a little loathe to give be cheating on my long time girlfriend Perl.  Things will be different, but hopefully better in the long run.

One thing I'm hooked on is Perl's regular expressions.  Nick Craig-Wood explains that regular expressions in Python are more clunky but...
Having made the transition from perl to python a couple of years ago, I find myself using regexpes much less. In perl everything looks like it needs a regexp, but python has a much richer set of string methods, eg .startswith, .endswith, good subscripting and the nice "in" operator for strings.
So hopefully things will be ok.

Tuesday, March 3, 2009

Thinking in another language #2

Almost every language teacher will say that "translating" is the wrong way to go about learning a foreign language. By that I mean thinking "I eat ice cream" and then translating word by word into another language.
My personal experience says we always translate*. When you are first learning, you translate word by word. As you progress, you translate phrase by phrase, sentence by sentence, and eventually whole ideas at a time. And I find that the "chunk-size" of your translation varys depending on how familiar you are with the subject matter. If I read technical or formal documents in my target language, I find myself translating much more than if I'm gossiping about people--an area where I have lots of experience :-)
* Ok, maybe not kids, but that is another discussion.

Thinking in another language #1

What does it mean to "think in another language"?  Is it an accurate measure of fluency in a foreign language?  Here is Foreign Language Doctor's opinion, and I think it makes sense.

Saturday, February 28, 2009

Remodeling is an investment?

How do you interpret this clip from an article on remodeling?

On average a Kitchen Remodel will yield an ROI of 80-100%! This is an amazing rate of return on any investment, but the added bonus is that as a homeowner you get to enjoy the benefits of your Kitchen Remodel until you sell your home.


Ok, so if I spend $100k on my kitchen, the price of my house will go up $180k to $200k....right?  After all, the definition of ROI is profit divided by cost.  The first $100k would go to pay back what I spent, and the remaining $80k to $100k would be my profit.  Then I saw this tidbit in another article :

Homeowners can recoup an average of 83% for a vinyl siding replacement and 78% of their investment for a mid-range bathroom renovation

Wait a minute!  Recoup 83% means you didn't get back all the money you spent.  That means a negative profit and a negative ROI of 17%!

So why do they state--incorrectly--that the ROI is 83%?  Because it sounds better.  Because it makes people spend more money at Home Depot.  I'm not saying that people shouldn't remodel their homes, just realize that you're doing it primarily for your own enjoyment and not to make money!

Thursday, February 19, 2009

Yelp == Mafia?

I'm a pretty big user of yelp.com, and there have always been concerns about competitor restaurants writing bad reviews.  But accusations of extortion --oh my!

Monday, January 26, 2009

G1 Android problems connecting to my Linksys WRT110 Wifi

The only way I could get the Android G1 to even acknowledge the existence of my wireless network was to change from "Mixed" mode to "Wireless G" mode only. Before that the SSID wouldn't even show up; after that it has worked perfectly.

Windows Vista Killed my Network

Good thing my wife noticed that whenever I booted up my brand-spanking-new HP Pavillion dv7-1232nr, our whole wireless network would stop working. Nobody had internet connectivity!

Strange. REALLY strange. An OS that can bring down your network?!!!

After wading though a lot of MS propaganda (they must hire blog writers on Mechanical Turk) that the problems are with "your outdated router" I came across this post which explains that you should disable IPv6 in Windows Vista. I'll repeat here:


Ok, I think I figured it out: I had the same problem as people on this thread ... the WRT110 router with firmware V 1.0.04 crashed as soon as my HP Laptop with Vista and 3945A chipset tried to connect. 100% consistent.
This is the fix that worked for me: I went to the Control Panel --> Network connections ... right clicked on the "wireless" icon and selected "properties" from the menu, then I UNCHECKED the "Internet Protocol Version 6 (TCP/IPv6)" entry ... and clicked OK. That's it, now it works reliably, never had a problem since!
I am disappointed in the Linksys service though, I would have figured they would have helped in this case instead of letting the customers spend HOURS to figure it out.

I also saw some posts which state that you should disable UPnP on the router. That didn't work for me, but YMMV.

Update (2010.03.11): This post seems to have figured everything out: http://keyliner.blogspot.com/2008/12/vista-unidentified-network-problem.html