Monday, September 27, 2010

Anonymous: Can we be friends on Facebook?

I absolutely love to show off my pictures :P

Sunday, September 26, 2010

Looks like everyone is getting famous by doing the thing they really like!
like these girls on youtube who make make-over videos, or this flickr guy, or this programmer who wrote youtube instant, or salman khan from khan academy (google 10^100), or blogger julie!
what should I do?

Friday, August 27, 2010

Karhunen-Loeve transform in java

Background knowledge and matlab code here.
The matlab code below is taken from the previous paper.
%number of examples
N=size(X,2);
%dimension of each example
M=size(X,1);
%mean
meanX=mean(X,2);
%centering the data
Xm=X-meanX*ones(1,N);
%covariance matrix
C=(Xm*Xm')/N;
%computing the eigenspace:
[U D]=eig(C);
%projecting the centered data
over the eigenspace
P=U'*Xm;

Helpful lecture video
Download JAMA package
Java code:
import Jama.*;

public class KLTransform {

//Matrix x[i,j]= jth feature in ith example
public Matrix k_lTransform(Matrix x)
{
 
   x = x.transpose();
     
   int nExample = x.getColumnDimension();

  //calculate mean
   Matrix mean = getMean(x);
  
   double[][] oneD = new double[1][nExample];
   for(int i = 0; i < nExample; i++)
       oneD[0][i] = 1;
   Matrix ones = new Matrix(oneD);
  
   //center the data
   Matrix xm = x.minus(mean.times(ones)); 

   //Calculate covariance matrix
   Matrix cov  = xm.times(xm.transpose());
  
   /*
   In the matlab code, the covariance matrix is divided with N (nExample). 
   Now cov and cov/nExample have the same eigenvectors but different eigenvalues. 
   In this code, the division doesn't make any difference as we are only 
   considering the eigenvectors. 
   But there are some cases, like in Kaiser-Guttman stopping rule 
   where only the eigenvectors with eigenvalue > 1 are chosen, 
   division might make a difference.
   */
   cov = cov.times(1.0/nExample);

   //compute eigen vectors
   Matrix eigenVectors = cov.eig().getV();

  //compute pca
   Matrix pca = eigenVectors.transpose().times(xm);
   return pca;
}
 
public Matrix getMean(Matrix x) {
 int nExample = x.getColumnDimension();
 int nFeature = x.getRowDimension();
  
 double[][] meanD = new double[nFeature][1];
 Matrix mean = new Matrix(meanD);
  
 for(int i = 0; i < nFeature; i++)
 {
   double avg = 0.0;
   for(int j = 0; j < nExample; j++)
   {
     avg+=x.get( i,j);
   }
   mean.set(i, 0, avg/nExample);
   
 }
 return mean;
}
//test 
public static void main(String[] args)
{
  KLTransform kl = new KLTransform();

  double [][] d = new double[][]{{1, 2, 3},{4,5,6}};
  Matrix x = new Matrix(d);
  Matrix pc = kl.k_lTransform(x);

  pc.print(pc.getRowDimension(), 2);

 }
}

Note that in the matlab code, number of examples is the number of columns that is each column is an example. But the java code assumes each row is an example. So the matrix X in matlab is the transpose of matrix X in java.
To test the java and matlab code:
run java with :
X=
[1 2 3]
[4 5 6]

run matlab with: X = [1, 4; 2, 5; 3, 6]

syntax highlighting tutorial

Friday, August 20, 2010

If I were

I am tagged by Mahmud in the "if i were" thing.
If I wait and try to think about the "correct" answers of these questions, i'll never have time to answer them, so I decided to do it in NOW, it's now or never :P


If I were a month, i'd be April, my Birth month :D, and this month is like me - sunny and bright !
If I were a day of the week, I’d be tuesday- not monday when everyone is grumpy, not weekends when everybody feels relaxed and I don't know why tuesdays are lucky for me.
If I were a time of day, I’d be 5 am- awesome start of a super awesome day. 
If I were a season, I’d be summer, colorful and  cheerful
If I were a planet, I’d be earth - green and full of people :D
If I were a sea animal, I'd be a mermaid I guess and always want to be a human.
If I were a direction, I am always "right"
If I were a piece of furniture, I’d be a rocking chair -always in motion
If I were a liquid, I’d be orange juice- tangy in taste but kills the bacteria :D
If I were a tree, I’d be a daffodil - I am totally narcisist
If I were a tool, I’d be a knife, really handy and versatile :P 
If I were an element, I could never be just one element, i'm too complex :D.
If I were a gemstone, I’d be ruby- I love red
If I were a musical instrument, I’d be a flute - subtle but unique.
If I were a color, I’d be RED
If I were an emotion, I’d be ":P"
If I were a fruit, I’d be orange - with the shape of earth and color of sun.
If I were a sound, I’d be the sound of laughter.
If I were a car, I’d be the cheapest but useful one :D
If I were food, I’d be khichuri & omelet - easy to make and you can never have too much.
If I were a taste, I’d be a mixed taste of a various of spices- a little bit of chili, a tinge of cinnamon, some cardamoms, some lime juice may be and a handful of cilantro :D
If I were a scent, I’d be the smell of lemon - fresh!!
If I were a pair of shoes, I’d be flip-flop -  down to earth and unpretentious
And if I were a bird, I’d be a rooster - I have a voice and sometimes I scream relentlessly even if no one is there to listen.
And If I were to tag people, If i could tag ANYONE then I'd tag the dead ones - to know what they feel about their earthy life now.

Saturday, August 07, 2010

find a file and delete it


Command:
find <where-to-look> -name <name-of-the-file> | xargs /bin/rm -f
Example:
I want to delete .svn folder from every directory
then the command would be
find <main-directory-name> -name .svn | xargs /bin/rm -rf

Source: Unix "find" command

Friday, August 06, 2010

You got to dance with the one that brought you
Stay with the one that wants you
The one who's gonna love you when all of the others go home
Don't let the green grass fool ya
Don't let the moon get to ya
Dance with the one that brought you and you can't go wrong

It was the best of times, it was the worst of times; 
it was the age of wisdom, it was the age of foolishness; 
it was the epoch of belief, it was the epoch of incredulity;
it was the season of Light, it was the season of Darkness; 
it was the spring of hope, it was the winter of despair;
we had everything before us, we had nothing before us

Wednesday, August 04, 2010

Awesome documentary: My architect


                 Louis Kahn




Its not everyday that I get to watch a documentary like this. To me, "documentary" has a synonym - Boring. So I tend to avoid documentaries as much I can. But this documentary made me captivated and changed my view on documentaries!

Its about Architect Louis Kahn's life, made by his son Nathaniel Kahn, who was 11 when Louis died at the New York Penn station. He had such an unusual life! I think EVERY person has an unusual life; different and unique life than everyone else. It's sad that we get to know only a few lives. There should be a rule that everyone has to make a movie about his/her life, so that other people can see and appreciate the extraordinary experiences and phenomenal circumstances that he/she might have witnessed.

Anyway, as long as I'm not the one making rules of life and there isn't one movie per person, at least watch the ones that are already here.

This is the ending of the movie in Bangladesh featuring Louis's biggest work Jatiyo Shonshod Bhaban
and TEDTalk by Nathaniel

Friday, July 30, 2010

error: "exit" was not declared in this scope

 If you gcc is <=3.4 --> add this #include <iostream>
in gcc 4.3 --> #include <cstdlib>


error:'strcmp' was not declared in this scope:

for c++ -> use #include<cstring>


--
Sheetal

--A journey of a thousand miles begins with a single step --

Friday, July 23, 2010

Puzzles

http://www.cs.cmu.edu/puzzle/
If someone dies, what should happen to their website/facebook page?
when I visit my dead friend's facebook page, I feel really creepy. I mean THis person is DEAD but he is still living in facebook!!! People are writing on his wall, his pictures and profile are saying things just like a living person.

Internet created a virtual world for us where we all live virtually, and do almost all the other things virtually,
shouldn't we also "die" virtually here?

Update**:
people thought about it before :D

How to Manage Your Online Life When You're Dead

Sunday, July 18, 2010

Something old, something new, Something borrowed, something blue

Two years ago this day, I got married.

It was a ... hmm... a normal day. Everything about it was normal.
I wore a beautiful shari and was not looking my best (sigh), I never look my best when I want to.
Anyway, our house was full with our relatives and my mom was very tensed (as usual :D).
Then Reza (my husband) with his family came at 7 pm, and the electricity went off. That made my mom more tensed, why does the electricity go off every time Reza comes? Does it mean all the "lights" of her daughter's life will go off after the marriage?
Actually, at that time electricity used to go off at 7pm EVERYDAY! But who'd remind her that!

The Kazi came to me to sign the contract. He started saying (very loudly), "ঠাকুরগাঁও নিবাসী জনাব [my father-in-law] এর পুত্র মো আলিমুর রেজা এর পক্ষ হইতে [at this point I started laughing] মোহাম্মদী শরীয়ত মোতাবেক আপনি ঢাকা জেলা নিবাসী জনাব [my father] এর কননা সাদিয়া আফরোজকে বিবাহের প্রস্তাব করিতেসি. আপনি এই বিবাহে সম্মতি থাকিলে আপনের উকিলের মাধ্যমে বলেন Alhumdullillah." (Son of [my father-in-law] is proposing to marry you, daughter of [my dad]. Say Alhumdullillah if you accept the proposal.)

I was trying my best not to laugh. Everyone around me was so serious and expecting me to cry, they would feel weird if they saw me laughing. It was really puzzling, too. In all bengali movies, I heard people say "Kobul" (I agree) three times when they get married, but now I have to say "Alhumdullillah?" Do I have to say both Kobul and Alhumdullillah? Anyway, I said Alhumdullillah once and then signed the contract. Someone from the back said he didn't hear me saying Alhumdullillah, so the Kazi asked me to say it louder. I almost screamed "Alhumdullillah" and this time couldn't suppress my laugh.

Then the Kazi went to Reza and took his sign on the contract. And we got married !!! Just like that! I was still confused if that was all. So I asked my uncle, "Is that all? Am I married now?" I don't know what was wrong with my question or the way I asked it, he started laughing and kept telling everyone my peculiar question. And I was thinking, like 5 days ago, my family was so hush hush about our relationship and we were not allowed to hold hands or go out together and now everything is "legal" and permitted? Who made these rules??? Thanks God, I'm not marrying a stranger.

It took me a while to get used to the fact that we are married and it's OKAY to live with him. There were thousands of moments when I felt "Oh my god, if my mom catches me with Reza now, she is going to get very angry!" and then I remembered "Oh I'm married now!"

I wanted to finish this post with something cool. But I'm pretty slow in coming up with wonderful witty things, so let me finish with whatever in my mind right now.
Marriage is such a huge thing in our society, specially for girls, I never understood why. My parents never allowed my going out alone or hanging out with friends for long and they used to say, "Do all these after you are married." "You can go on tours with your husband." I've seen same things being told to many (all!) bengali girls along with other bullshits like "You can make your hair short if your husband likes, keep it longer till you get married." "You should put on make-ups and wear gold jewelry  after you get married, doing all these before marriage are not signs of a good girl." "Don't make a habit of spending money, what if your future husband doesn't like it?" "Don't be a dancer or singer, your future husband might not like it." "You shouldn't stay out in the sun too much, guys might not choose you to marry if your complexion is dark." As if a girl's life is going to start only after she gets married. And she has to shape herself so that society thinks she is going to be a "good" bride. Is a guy growing up shaping himself so that he can be a "good" husband? Society fills up our head with these fairy tales about a prince who marries a beautiful poor girl and makes her a queen. Is there any fairy tale about a queen marrying a poor boy and making him just her husband? There are many in real life but not in fairy tales. And also every time these stories are about "someone else will come to your life and make you happy," why don't they teach us that no one can make you happy unless you learn to make yourself happy?

May be they do, may be we need to grow up to realize the true meanings of those stories.

After my two years of married life, I think marriage is a wonderful experience that makes us grow up in many ways and teaches us to appreciate life. So, cheers to the constitution of marriage and cheers to whoever established this rule.

Wednesday, June 23, 2010

Attitude is Altitude

Meet Nick Vujicic, one of the most motivational speaker who has no arms and legs.

Sunday, May 30, 2010

Saturday, May 22, 2010

Resource 'tokenizers/punkt/english.pickle' not found.

Full solution is in here
For Mac, do this
sudo python -m nltk.downloader -d /usr/share/nltk_data all