Monday, April 21, 2008

Does Java pass by reference or pass by value?

A compact answer to this question will be

"Java passes the reference of the object by value".
So what does it mean to pass the reference of the object by value.
It means that if an object is passed to a method, then the object itself can be altered but not its reference. Because the reference of the object is passed by value. For example consider a object O and let the reference of the object O be x. Now when you pass the object O to a method, the VM internally makes a copy of x, that means there is another reference y which points to the same location as x does.
But x >< y. Now this means whenever you pass a object to a method, the object has atleast two references. Thus objects in java can be altered by passing to a method but they cannot be swapped with another object or assigned to some other object or something like that.

Thursday, April 3, 2008

Useful Firefox Addons

Here I would like to mention some of the Addons to Firefox that I find very useful.
1. Many of the people would like to restore their browser session once they boot their personal computer. So that they need not open each and every tab once they start their browser. There are session restoring features in Firefox but they are not upto the mark. So the best session restoring addon according to me is Tab Mix Plus and it can be found at the Tab Mix Plus
2. For those who are into web development there are two addons that I wud like to suggest. The first and the most notable addon being firebug. This addon is available at the Firebug
This addon has a long list of features. But I would like to point out my favorite features. First being the inspect element feature that will enable you to see the html source of any element that you want to locate. For this you need to right click on the element and select the Inspect Element option. Now many people want to look at the contents of the response that has come back and also check whether the request made is proper or not. For this you need to select the Net tab of firebug and then inspect the contents of request and response. One can also view the contents of the XHRs that are being made. Viewing the contents of XHR is a pretty nifty feature of Firebug.
The second addon that is not very popular being Web Developer. This is at the Web Developer. The feature of this addon which is not present as it is in Fire Bug being the View Layout option. This option enables one to view the layout of the page properly. Fire Bug also has this option but not as sophisticated as Web Developer.
3. The third addon being the stumble upon addon which is my favorite addon. Now this addon not only allows you to stumble but also record any pages that you want to record. This is much more useful for me because I visit certain pages and I dont want to loose their pointer at any cost. So as soon as I find any page that needs to be stored I wud mark it as thumbs up. Then later in time I can retrieve the list of pages that I liked and I can easily search for the wanted pages. This addon however is present in the stumble upon home page from where one can obtain and install stumble upon add on.

I will be adding to this list as soon as I find any new and useful addons..

Tuesday, April 1, 2008

Precision Vs Recall

In all the applications involving Information Retrieval one of the main concerns would be to balance Precision and Recall parameters. The general application involves a scenario where a query is submitted by the user and the documents that match the query in the corpus are retrieved using some information retrieval model. Well known information retrieval models include Vector Space model, Latent Semantic Indexing and several other Probabilistic models.

Precision refers to the ratio --> Number of relevant documents retrieved / Total number of retrieved documents.
Recall refers to the ratio --> Number of relevant documents retrieved / Total number of relevant documents.

Now one can observe that Recall will be 1 if one returns all the documents in the corpus but the whole application's performance will be in jeopardy if one returns all the documents in the corpus thus rendering the application useless. On the other extreme is when we return no documents, then the Precision is infinity. But even then the application is unusable because no documents are rendered to the user.
So the balance between precision and recall has to be established in the applications involving the Information Retrieval. Due to the ambiguities in the natural language many irrelevant documents are returned resulting in a text search applications with low precision. One of the main reasons that Google has established its ground as a giant is due to its Page rank algorithm which increases the precision a lot. So while developing the applications one can improve the performance by giving the proper weights to precision and recall as required by the specifications of a particular application.
For example there might be some applications where all the relevant documents need to be displayed irrespective of the total number of the retrieved documents. In this case one needs to give a high weight to the recall parameter while designing the search query. Commercial search engines require a high degree of precision because the number of web pages (each web page can be viewed as a document and the set of all web pages is the corpus) is in zillions. There are several measures like F1 measure in which precision and recall are evenly weighted.