<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4425557513103987115</id><updated>2011-07-29T09:41:11.553-07:00</updated><category term='yacc'/><category term='higher education'/><category term='audio'/><category term='economics'/><category term='shell scripting'/><category term='java'/><category term='hobby'/><category term='tutorial'/><category term='video'/><category term='coding tips and tricks'/><category term='lex'/><category term='plug in'/><category term='rhythmbox'/><category term='machine learning'/><category term='ubuntu'/><category term='algorithms'/><category term='complexity'/><category term='general'/><category term='health'/><category term='Data mining'/><category term='mplayer'/><category term='database'/><category term='notes'/><title type='text'>dimaag kehta hain.. :-)</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4425557513103987115.post-2949068466736737938</id><published>2011-02-28T08:40:00.000-08:00</published><updated>2011-02-28T08:45:03.495-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='yacc'/><category scheme='http://www.blogger.com/atom/ns#' term='notes'/><category scheme='http://www.blogger.com/atom/ns#' term='tutorial'/><category scheme='http://www.blogger.com/atom/ns#' term='lex'/><title type='text'>lex_ing and regex_ing</title><content type='html'>During engineering, this topic came and went.. w/o bothering me much.. just a small assignment on parser and done! But.. no.. the practical exam threw on my face a problem on designing parser in C (not with lex/yacc or generated one) and then I realized - well.. I had not understood it!&lt;br /&gt;&lt;br /&gt;This was like 6+ years back.. and now I am here.. writing regex and grammar to generate parser with lex-yacc! That's life! :D ... And... it's very good!&lt;br /&gt;&lt;br /&gt;Just came across a nice tutorial on lex yacc. Find it &lt;a href="http://poincare.matf.bg.ac.rs/%7Efilip/pii/Vezbe/regex/Regex.pdf"&gt;here&lt;/a&gt;. Even if you keep technical details apart and just glance through the tutorial, you would get a new outlook towards lex-yacc - specially regex - writing them and debugging them when they don't behave the way you expect them to..!&lt;br /&gt;&lt;br /&gt;A very good and important thing I realized during this exercise is as follows. Parser design can easily be segregated in lex and yacc when you know your application well. Taking some reference from the tutorial link posted, for example - a simplified regex could serve your purpose given that you want to capture occurrences of a pattern; and you need a bit complex regex when you want to validate inputs. (Again from the tutorial,) For example, if you want to list down html tags in the browsed web crawl, all you need is a simple pattern that captures anything between a "&amp;lt;" and a "&amp;gt;". You need not __validate__ that __anything__. The basic assumption here - that you are expecting to get positive (meaning correctly matching with pattern) cases more in such scenario inherently comes from the application - i.e. capturing tags from web crawl. In an application of say - writing a SQL kind of language, you expect to get negative cases as probably as positive ones and just capturing __anything__ would not work. Again, I would say that it depends on how you look at it. You could always write a light weight regex and a comparatively heavy code in back end to validate your verbose input. It's up to you! But, understanding internals of how a regex engine works (given in the tutorial, for many cases), and mainly understanding its complexity and contrasting it with the complexity you would introduce by writing validation in code - is definitely important.&lt;br /&gt;&lt;br /&gt;Indeed, a nice bunch of information!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4425557513103987115-2949068466736737938?l=non-non-sense.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/2949068466736737938/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4425557513103987115&amp;postID=2949068466736737938' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/2949068466736737938'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/2949068466736737938'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/2011/02/lexing-and-regexing.html' title='lex_ing and regex_ing'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4425557513103987115.post-8842963313162878097</id><published>2010-09-24T10:39:00.000-07:00</published><updated>2010-09-24T10:39:14.126-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='video'/><category scheme='http://www.blogger.com/atom/ns#' term='shell scripting'/><category scheme='http://www.blogger.com/atom/ns#' term='mplayer'/><title type='text'>mplayer - not playing files with _space_ characters</title><content type='html'>Recently I upgraded all packages on Ubuntu and somehow since then I could not play video files with vlcplayer! Not just that, somehow Realplayer and default movie player lost the codecs they used to previously use! After this miracle, the only option left with me was to try mplayer. I had heard that it supports many common formats and so on. I tried that and faced another issue. It magically could not play files having space characters in it!!&lt;br /&gt;&lt;br /&gt;Initially I used to manually rename the file from browser before double clicking it for mplayer. Later on I found this very hectic when following happened. I renamed a long file name replacing some 7-8 spaces by underscores (Note: spaces, it converts to %20 and cannot play such file, underscore works!) and soon realized that I wanted to see another episode (with similar long file name)!!! So, I got irritated a lot and said to my friend that I will soon write a script to rename all files such the spaces are replaced by underscores. Now, I realized that all main / important video files (movies, acad lectures and so on) were on portable hard disk and the list will get augmented day after day as I get something good from some source, I will have a copy. Thus, this method sounded a bit overkill - to rename all file names just like that!&lt;br /&gt;&lt;br /&gt;I then did following.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;I wrote following lines in a file ~/scripts/mplayer_helper.sh&lt;br /&gt;&lt;blockquote style="background-color: #f4cccc; color: #660000; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;#!/bin/bash&lt;br /&gt;fname20=`echo $1 | sed 's/ /\\ /g'`&lt;br /&gt;fname=`echo $1 | sed 's/ /_/g'`&lt;br /&gt;mv "$fname20" "$fname"&lt;br /&gt;mplayer $fname&lt;/blockquote&gt;The idea here is simple. Just create a file name (do some trials on command line first as to how exactly "mv" expects the input.) replacing space by underscore and replace file using "mv" command. Once that is done, invoke mplayer on renamed file.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Then I made it executable using&lt;br /&gt;&lt;blockquote style="background-color: #f4cccc; color: #660000; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;chmod +x ~/scripts/mplayer_helper.sh&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;Then I created a soft link to this executable inside /usr/bin/ as follows:&lt;br /&gt;&lt;blockquote style="background-color: #f4cccc; color: #660000; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;cd /usr/bin&lt;br /&gt;sudo ln -s ~/scripts/mplayer_helper.h sudomplayer&lt;/blockquote&gt;&lt;/li&gt;&lt;li&gt;Now, when I want to open video from browser, I simply right-click it and say "Open with". Then, I expand the option "Use custom command" and write "/usr/bin/sudomplayer" and say "Open".&lt;/li&gt;&lt;li&gt;This not only opens the video by run-time substituting spaces with underscores but also once opened, adds this sudo application into the list of applications. Additionally, sudomplayer will be the default application shown for that file format then onwards.&lt;/li&gt;&lt;/ol&gt;Easy! Isn't it!&lt;br /&gt;&lt;br /&gt;But, there is a glitch, what if not only the file to be played but also the recursive folders it is contained in have spaces. mplayer fails then as well! But, the solution is simple! Modify the script to take care of that as follows.&lt;br /&gt;&lt;blockquote style="background-color: #f4cccc; color: #660000;"&gt;#!/bin/bash&lt;br /&gt;xmessage -center -nearmouse Note that this tries to rename the files so this might fail if the file path does not have write permissions&lt;br /&gt;i=2&lt;br /&gt;token=`echo $1 | cut -d"/" -f$i`&lt;br /&gt;more=`echo $1 | cut -d"/" -f$i | grep -i ^$ | wc -l`&lt;br /&gt;currDir=""&lt;br /&gt;while [[ $more -eq 0 ]]&lt;br /&gt;do&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; currDir=$currDir/&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; token=`echo $1 | cut -d"/" -f$i`&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name20=`echo $token | sed 's/ /\\ /g'`&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dir20=$currDir$name20&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name=`echo $token | sed 's/ /_/g'`&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dir=$currDir$name&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [[ $dir20 != $dir ]]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [[ -a $dir ]]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmessage -center -nearmouse $dir File exists! Aborting!!&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mv "$dir20" "$dir"&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; currDir=$dir&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i=`expr $i + 1`&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; more=`echo $1 | cut -d"/" -f$i | grep ^$ | wc -l`&lt;br /&gt;done&lt;br /&gt;mplayer $currDir&lt;/blockquote&gt;The idea is here, to go one directory at a time. Try to rename it and then keep track of current directory such that now next level directory can be renamed. But, WARNING!! What if the current directory is inside "/home/xyz/abc/"? One might not have permission to replace "xyz" with "xyz" inside /home/. There are two ways to look at it. First, mostly the filenames with space character won't appear in such so_called __system_prohibited__ paths and even if they appear, it's better not to mess with it (at least automatically!) and thus, the initial "xmessage" serves the purpose. Another WARNING! is - what if we are trying to rename directory "dir with spaces" and there already exists a directory called "dir_with_spaces". To prevent such collisions, we will terminate the script once we find such case. Work around to this problem is to use some weird set of characters instead of "_", say like "_-_" or so; but, then if this script is run quite frequently, then your filesystem (portable hdd in my case) will be full of such weird names! ;)&lt;br /&gt;&lt;br /&gt;Anyways, another (probably best?) way is - just Google around! Then will tell you some ways to get around to this problem of mplayer not playing files with space characters. But, then you will miss all the scripting_fun! :D :P&lt;br /&gt;&lt;ol&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4425557513103987115-8842963313162878097?l=non-non-sense.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/8842963313162878097/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4425557513103987115&amp;postID=8842963313162878097' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/8842963313162878097'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/8842963313162878097'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/2010/09/mplayer-not-playing-files-with-space.html' title='mplayer - not playing files with _space_ characters'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4425557513103987115.post-476372511523279901</id><published>2010-05-29T06:08:00.000-07:00</published><updated>2010-05-29T06:08:02.745-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='rhythmbox'/><category scheme='http://www.blogger.com/atom/ns#' term='audio'/><category scheme='http://www.blogger.com/atom/ns#' term='general'/><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><category scheme='http://www.blogger.com/atom/ns#' term='plug in'/><title type='text'>Rhythmbox Music player - password window popping issue!</title><content type='html'>I have been using Rhythmbox music player since almost 3 years now. Suddenly one day, it started popping a Give_ur_password type of window at every track. I used to close the box, then it would pop up again for thrice or so. It looked like the following.&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_iLEvmgkXNwE/TAEPo4jCrzI/AAAAAAAAA5c/hDQi0rt2cwA/s1600/popup.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="250" src="http://1.bp.blogspot.com/_iLEvmgkXNwE/TAEPo4jCrzI/AAAAAAAAA5c/hDQi0rt2cwA/s400/popup.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;I tried Google-ing of course, but could not find anything. There were some posts regarding why / how some plug-ins for Rhythmbox keep popping windows. I did not find anything related to password window specifically. Still, I opened Edit-&amp;gt;Plug-ins and observed that few plug-ins were enabled. For no apparent reason, I disabled the plug-in for Cover art (as shown below) and never got those disturbing pop up windows again!&lt;br /&gt;&lt;br /&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_iLEvmgkXNwE/TAEQ_WG6UoI/AAAAAAAAA5k/TweaW-wXn5c/s1600/plugin.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="250" src="http://3.bp.blogspot.com/_iLEvmgkXNwE/TAEQ_WG6UoI/AAAAAAAAA5k/TweaW-wXn5c/s400/plugin.jpg" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;What I don't understand though is, that plug in was always enabled afaik, because I never explicitly enabled / disabled it in past, then why suddenly after almost 2.5 years, it started popping up windows?! Another thing is, as shown in first image, there is something called "xml.amazon-proxy caching server" - Have no clue how it could be related to cover art of an album!&lt;br /&gt;&lt;br /&gt;Anyways, will definitely post the explanation if I can find one, for time being let me enjoy the pop-up_window_free Rhythmbox!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4425557513103987115-476372511523279901?l=non-non-sense.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/476372511523279901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4425557513103987115&amp;postID=476372511523279901' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/476372511523279901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/476372511523279901'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/2010/05/rhythmbox-music-player-password-window.html' title='Rhythmbox Music player - password window popping issue!'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_iLEvmgkXNwE/TAEPo4jCrzI/AAAAAAAAA5c/hDQi0rt2cwA/s72-c/popup.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4425557513103987115.post-700006352356054076</id><published>2010-04-15T01:33:00.000-07:00</published><updated>2010-05-19T03:20:13.101-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='video'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithms'/><category scheme='http://www.blogger.com/atom/ns#' term='complexity'/><title type='text'>Approximate if you can do it in polytime!</title><content type='html'>&lt;div style="color: #eeeeee; font-family: inherit;"&gt;The main idea behind approximation algorithms is as follows. When one has to solve a problem which is proved to be NP-Complete, one has two choices.&lt;/div&gt;&lt;ol style="color: #eeeeee; font-family: inherit;"&gt;&lt;li&gt;Use usual algorithm and get answer in non-polynomial time (most of the times exponential) and be ready to wait until eternity OR&lt;/li&gt;&lt;li&gt;Compromise on the quality of answer but get things done faster&lt;/li&gt;&lt;/ol&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;As suggested by 2 above, approximation algorithms have the same aim. Instead of finding the correct, optimal, best possible solution to the given problem, they try to find an approximated one; but they guarantee to find it in polynomial time so that they run faster. Now the question&amp;nbsp; is - even if they are faster, how much does the quality of solution degrades? This is measured by Approximation factor or Approximation ratio.&amp;nbsp; This factor or ratio basically captures how far we are from doing the best i.e. from the optimal. Consider the optimization in terms of minimization. Suppose a minimization problem is NP-Complete and suppose the optimal solution has the value 5; then if any proposed approximation algorithm, that is the algorithm that solves the problem correctly in polynomial time gives the solution whose value is 7.5 then we will say that we have got 1.5 times more than the optimal one; i.e. we are doing 1.5 times worse. So, here the approximation factor = approximation ratio = 7.5/5 = 1.5. Note that in case of minimization problem, if we call OPT as value of optimal solution and V as value of approximate solution then V &amp;gt;= OPT always; i.e. V can be equal or worse (here more, being minimization problem) than OPT and thus approximation ratio for minimization problem is always greater than or equal to 1. Similarly for maximization problem, V &amp;lt;= OPT and thus approximation ratio is always less than or equal to 1.&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;Thus, one comes up with an (approximation) algorithm A such that&lt;/div&gt;&lt;ul style="color: #eeeeee; font-family: inherit;"&gt;&lt;li&gt;It solves the problem in polynomial time&lt;/li&gt;&lt;li&gt;One can give proof of correctness for A&lt;/li&gt;&lt;li&gt;It does not degrade the quality of solution too much; i.e. one can come up with the reasonable approximation ratio for A and can prove that for the general case&lt;/li&gt;&lt;/ul&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;There exists many ways to come up with approximation  algorithms and to prove that the have a reasonable approximation ratio. One such recipe is as follows.&lt;/div&gt;&lt;ul style="color: #eeeeee; font-family: inherit;"&gt;&lt;li&gt;Suppose it is the maximization problem so that the value V &amp;lt;= OPT where V is the value for the solution returned by any approximation algorithm. So we have to come up with a ratio k s.t. V is at most k times worse than OPT.&lt;/li&gt;&lt;li&gt;In order to prove that V is at most k times worse than OPT, we have to know what is OPT which is not possible because that itself will take non-polynomial time in general case.&lt;/li&gt;&lt;li&gt;Suppose we know some number M such that the optimal solution has maximum cost of M then OPT &amp;lt;= M considering all possible cases.&lt;/li&gt;&lt;li&gt;Thus, if we can prove that V is at most k times worse than M, it is guaranteed that V is at most k times worse than OPT as well. Because, given that V &amp;gt;= k*M and M &amp;gt;= OPT, we get V &amp;gt;= k*OPT&lt;/li&gt;&lt;li&gt;For example, if the OPT is 100, and we know that M is 120. Then suppose V is 80 (the best we can achieve with approximation algorithm) then k = V / M = 80 / 120 = 2/3 meaning we can achieve 2/3 rd of the maximum possible solution value. We note that V / OPT is 80 / 100 = 4/5 which is always more than 2/3. Thus considering the upper bound M is enough.&lt;/li&gt;&lt;li&gt;For minimization problem as we shall see below, we have to consider lower bound.&lt;/li&gt;&lt;/ul&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt; &lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;I came across a nice &lt;a href="http://www.youtube.com/watch?v=Dd0XNsAkkqE"&gt;lecture&lt;/a&gt; by Prof. Abhiram Ranade (IIT Bombay). In this lecture, in addition to introducing the basics of approximation algorithms and defining above mentioned notions, Sir also illustrates the approximation algorithms designed for two of the NP-Complete problems. One of them (my favorite and the easier one :D) is briefly explained below.&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;(&lt;b&gt;Note&lt;/b&gt;: I have tried to explain the problem and its approximation algorithm the way I understood it, so it is recommended to go through the original &lt;a href="http://www.youtube.com/watch?v=Dd0XNsAkkqE"&gt;lecture&lt;/a&gt; by Ranade Sir)&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;&lt;b&gt;Metric TSP (Traveling Salesperson Problem)&lt;/b&gt;&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;&lt;b&gt;Input&lt;/b&gt;: A graph G with N cities, a matrix D giving distance between a pair of cities s.t. D is a metric.&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;A distance D measure is a metric if&lt;/div&gt;&lt;ol style="color: #eeeeee; font-family: inherit;"&gt;&lt;li&gt;D[i,i] = 0 for all i&lt;/li&gt;&lt;li&gt;D[i,j] = D[j,i] for all i,j (D is Symmetric)&lt;/li&gt;&lt;li&gt;D[i,j] &amp;lt;= D[i,k] + D[k,j] for all i, j and k (D follows Triangle Inequality)&lt;/li&gt;&lt;/ol&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;&lt;b&gt;Output&lt;/b&gt;: A cycle in G that goes through every city exactly once and has shortest length (in terms of distance values in D)&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;&lt;b&gt;Recipe&lt;/b&gt;:&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;This will follow the recipe mentioned above. This being the minimization problem, we will come up with a lower bound. For the given graph G, suppose we know the optimal tour and we remove an edge from it. As the required output is the cycle containing all vertexes in G, the edge_removed_tour is the spanning path in G (spanning = containing all vertexes). Thus this is the spanning tree of G because it contains all vertexes and no cycle. Consider the minimum spanning tree T in G which has cost M. Now as any other spanning tree in G is as expensive as T so the spanning tree that we came up with, by removing an edge from the optimal tour can have length no less than that of MST, which we called as M. So, length of edge_removed_tour &amp;gt;= M.&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;As, length of (optimal) tour &amp;gt; length of edge_removed_tour (obvious), so we get&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;length of (optimal) tour &amp;gt;= M&lt;br /&gt;Here, LHS is nothing but OPT and thus M is the lower bound on OPT.&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;So, we come up with an algorithm that has solution with value V no more than twice of M i.e. V &amp;lt;= 2 * M.&lt;/div&gt;&lt;div style="color: #eeeeee; font-family: inherit;"&gt;The algorithm and its correctness is described in the &lt;a href="http://www.youtube.com/watch?v=Dd0XNsAkkqE"&gt;lecture&lt;/a&gt;.&amp;nbsp; The main idea used is triangle inequality property of D being a metric.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4425557513103987115-700006352356054076?l=non-non-sense.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/700006352356054076/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4425557513103987115&amp;postID=700006352356054076' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/700006352356054076'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/700006352356054076'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/2010/04/approximate-if-you-can-do-it-in.html' title='Approximate if you can do it in polytime!'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4425557513103987115.post-7834294970861910752</id><published>2010-01-11T21:27:00.000-08:00</published><updated>2010-01-11T21:28:37.463-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Data mining'/><category scheme='http://www.blogger.com/atom/ns#' term='machine learning'/><title type='text'>Precision-recall trade off ~ misclassification cost</title><content type='html'>While I was reading &lt;a href="http://research.microsoft.com/en-us/um/people/cmbishop/prml/"&gt;Pattern recognition and ML by Bishop&lt;/a&gt;, I realized a beautiful relationship between misclassification cost and precision recall. This might be well-known of course, but it's important for me as I myself realized it. :)&lt;br /&gt;&lt;br /&gt;We know that precision-recall concept comes from Information retrieval kind-of a setting while misclassification cost comes from decision theory problems. In IR, given a set of true results i.e. T, and a set of retrieved results say R, &lt;a href="http://en.wikipedia.org/wiki/Precision_(information_retrieval)"&gt;precision&lt;/a&gt; is simply the fraction of true results in the set R. i.e. precision = #intersection(R,T) / #R. For example, suppose we know *all* the web pages that exist in the Web; then the set of pages which should be retrieved by a search engine are say T of size |T|. The search engine may retrieve a set R with size |R|. Then, if only 10 of these |R| pages are in T, then R's precision is 10 / |R|. Intuitively, R is more precise / exact if it has less not_required results. One may think of |R| &gt;&gt; |T| and that R contains all pages from T and many more extra results. Here, one says that R could "recall" everything in T but at the same time, it also made lots of mistakes. It is like, it took many trials on a puzzle and solved a puzzle 100 times correct while num_trials were 1000+. But in general if it could retrieve 10 pages which are in T, we say that it's &lt;a href="http://en.wikipedia.org/wiki/Recall_(information_retrieval)"&gt;recall&lt;/a&gt; is 10 / |T| i.e. out of |T| correct pages, it could retrieve 10. This also shows that there is a trade off between precision and recall because as num_trials increase, recall improves at the cost of precision.&lt;br /&gt;&lt;br /&gt;Little off-topic but relevant: It's said that "practice makes man perfect". If we consider practice being making many trials, then as num_trials increase, due to practice one gets better results.&lt;br /&gt;&lt;br /&gt;While I was reading the book, on page 41, I came across the misclassification cost involved in the decision theory. It says- We account for the misclassification cost because we don't want to miss on important predictions. Like in the example given for the two-class classification about whether a person is healthy or has cancer, it's important that we make no mistakes when the true class is "cancer-patient" as the consequences of these mistakes are dangerous. It also says that misclassification costs are such that we don't mind if a healthy person is predicted to be having cancer in order to not miss any patient which has cancer in reality. This is basically a trade-off between decisions. By this, we are looking for more recall even though we lose the precision.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4425557513103987115-7834294970861910752?l=non-non-sense.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/7834294970861910752/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4425557513103987115&amp;postID=7834294970861910752' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/7834294970861910752'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/7834294970861910752'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/2010/01/precision-recall-trade-off.html' title='Precision-recall trade off ~ misclassification cost'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4425557513103987115.post-2936355184165260211</id><published>2009-12-29T21:44:00.000-08:00</published><updated>2010-01-11T21:28:17.414-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='notes'/><category scheme='http://www.blogger.com/atom/ns#' term='algorithms'/><category scheme='http://www.blogger.com/atom/ns#' term='complexity'/><title type='text'>Beautiful theory of NP-completeness</title><content type='html'>I am fascinated by this. I learned about it in one of the courses here at IIT Bombay and could not stop myself from reading this wonderful book (which one of my friends suggested to me). I hope you will enjoy the noted I wrote for myself, which are at &lt;a href="http://nonnonsenseblog.googlegroups.com/web/computers_and_intractability_ch_1_2.pdf?gda=apSlXFwAAACHM7ehcqb3e25jK3Y_yhZ3cEjgCUAPPNdofAqEyw-XwjopMxTdRAzC2LRqdSqk4DC2CqaBWbhYkrlm85kRELdYQ6po9127roLE5W7l7RiCjM_DpNGDR--rmmJfdnjV3oU&amp;gsc=AnudWgsAAAB8xkrXZpybFpK_AJOkmXSo"&gt;this&lt;/a&gt; link.&lt;br /&gt;&lt;br /&gt;Please give any suggestions / comments / point out errors / typos / serious mistakes or anything.&lt;br /&gt;&lt;br /&gt;Happy reading!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4425557513103987115-2936355184165260211?l=non-non-sense.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/2936355184165260211/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4425557513103987115&amp;postID=2936355184165260211' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/2936355184165260211'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/2936355184165260211'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/2009/12/beautiful-theory-of-np-completeness.html' title='Beautiful theory of NP-completeness'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4425557513103987115.post-4157311763219814209</id><published>2009-12-10T22:31:00.000-08:00</published><updated>2009-12-10T23:06:18.191-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='higher education'/><title type='text'>Ph.D. info</title><content type='html'>Well, this is a collection of articles / write ups etc. which I found / got from friends while gathering information about Ph.D. Hope this will be useful for others.&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.cs.virginia.edu/%7Erobins/YouAndYourResearch.html"&gt;You and your research - Must read&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://cseweb.ucsd.edu/%7Emihir/phd.html"&gt;The Ph.D. experience - Again, a must read&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.cs.cmu.edu/%7Eharchol/gradschooltalk.pdf"&gt;Another nice talk&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4425557513103987115-4157311763219814209?l=non-non-sense.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/4157311763219814209/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4425557513103987115&amp;postID=4157311763219814209' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/4157311763219814209'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/4157311763219814209'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/2009/12/phd-info.html' title='Ph.D. info'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4425557513103987115.post-5272844255969454295</id><published>2009-10-02T09:37:00.000-07:00</published><updated>2009-10-02T10:02:13.203-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='video'/><category scheme='http://www.blogger.com/atom/ns#' term='hobby'/><category scheme='http://www.blogger.com/atom/ns#' term='ubuntu'/><title type='text'>Video cutter on ubuntu</title><content type='html'>Since long I was searching for the video of a marathi movie song, which I just love to listen to. I could not find it on youtube. The only way (which my friend Aashay once suggested) was to cut the song from the movie itself and make my own video for that song. He being the expert at this, it was quite easy for him to just "suggect" that! Moreover, I use nothing else than ubuntu - thus I had to find some way on my own.&lt;br /&gt;&lt;br /&gt;Little bit of Google-ing and I had the software installed on my laptop for video cutter / editor. It is &lt;a href="http://ubuntuforums.org/showthread.php?t=60764"&gt;"avidemux"&lt;/a&gt;. It seemed to be an easy tool after I had gone through the ubuntu forum post messages. But..!!  I opened that movie with avidemux and it popped an error message saying - "trouble initializing audio device". I  checked preferences. (Note:- After you open the movie, it won't play automatically.  You have to click "play". Also, while it is being played, it won't open "preferences" window.. weird though!! But, happens!!) In preferences, I set audio device to  "default" as shown in the screen shot. I don't know why and how , but it did play audio too!! This ofcourse I got after some more Google-ing.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_iLEvmgkXNwE/SsYvhrH5KuI/AAAAAAAAAms/R9tCzoJKVt0/s1600-h/avidemux.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 282px;" src="http://4.bp.blogspot.com/_iLEvmgkXNwE/SsYvhrH5KuI/AAAAAAAAAms/R9tCzoJKVt0/s400/avidemux.jpg" alt="" id="BLOGGER_PHOTO_ID_5388046259753396962" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="display: block;" id="formatbar_Buttons"&gt;&lt;span class="on down" style="display: block;" id="formatbar_CreateLink" title="Link" onmouseover="ButtonHoverOn(this);" onmouseout="ButtonHoverOff(this);" onmouseup="" onmousedown="CheckFormatting(event);FormatbarButton('richeditorframe', this, 8);ButtonMouseDown(this);"&gt;&lt;img src="http://www.blogger.com/img/blank.gif" alt="Link" class="gl_link" border="0" /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Well.. I loved it!! My first step towards becoming the "video-editor-by-hobby" ;) :D&lt;br /&gt;&lt;br /&gt;Btw, this is the video that I cut with it. It's a nice classical based marathi song, sung by Sawanee Shende.&lt;br /&gt;&lt;br /&gt;&lt;object width="320" height="266" class="BLOG_video_class" id="BLOG_video-8f2427ad443041c2" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"&gt;&lt;param name="movie" value="http://www.youtube.com/get_player"&gt;&lt;param name="bgcolor" value="#FFFFFF"&gt;&lt;param name="allowfullscreen" value="true"&gt;&lt;param name="flashvars" value="flvurl=http://v24.nonxt1.googlevideo.com/videoplayback?id%3D8f2427ad443041c2%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1331386788%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D3DF2FF5A1EE7D6D6770CE93C24C15FFB38E52B50.434F0AEB736244154C915CD904951BF04FD4CDB5%26key%3Dck1&amp;amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D8f2427ad443041c2%26offsetms%3D5000%26itag%3Dw160%26sigh%3DWKH6lE8eAcX_bsaC0eCyn6ZlP7g&amp;amp;autoplay=0&amp;amp;ps=blogger"&gt;&lt;embed src="http://www.youtube.com/get_player" type="application/x-shockwave-flash"width="320" height="266" bgcolor="#FFFFFF"flashvars="flvurl=http://v24.nonxt1.googlevideo.com/videoplayback?id%3D8f2427ad443041c2%26itag%3D5%26app%3Dblogger%26ip%3D0.0.0.0%26ipbits%3D0%26expire%3D1331386788%26sparams%3Did,itag,ip,ipbits,expire%26signature%3D3DF2FF5A1EE7D6D6770CE93C24C15FFB38E52B50.434F0AEB736244154C915CD904951BF04FD4CDB5%26key%3Dck1&amp;iurl=http://video.google.com/ThumbnailServer2?app%3Dblogger%26contentid%3D8f2427ad443041c2%26offsetms%3D5000%26itag%3Dw160%26sigh%3DWKH6lE8eAcX_bsaC0eCyn6ZlP7g&amp;autoplay=0&amp;ps=blogger"allowFullScreen="true" /&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4425557513103987115-5272844255969454295?l=non-non-sense.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/5272844255969454295/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4425557513103987115&amp;postID=5272844255969454295' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/5272844255969454295'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/5272844255969454295'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/2009/10/video-cutter-on-ubuntu.html' title='Video cutter on ubuntu'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_iLEvmgkXNwE/SsYvhrH5KuI/AAAAAAAAAms/R9tCzoJKVt0/s72-c/avidemux.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4425557513103987115.post-380997290818849758</id><published>2009-08-29T22:21:00.000-07:00</published><updated>2009-08-29T22:52:27.653-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='coding tips and tricks'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><title type='text'>Inserting into mysql table from Java code</title><content type='html'>This post gives sample implementation of an interface which will insert records in a given table.&lt;br /&gt;&lt;br /&gt;Assumptions:&lt;br /&gt;1. mysql_connector driver is in build path&lt;br /&gt;2. List of records is built off line.&lt;br /&gt;3. Database connection is already made.&lt;br /&gt;&lt;br /&gt;Procedure:&lt;br /&gt;As shown in the snippet of code, the method takes 5 parameters, as mentioned in the comment.&lt;br /&gt;&lt;blockquote&gt; /**&lt;br /&gt;  * @param tableName name of the table&lt;br /&gt;  * @param numValues number of values to insert &lt; = num columns&lt;br /&gt;  * @param dataTypes their datatypes (string, int etc)&lt;br /&gt;  * @param columnNames column names to add values for &lt;br /&gt;  * @param values actual values in same sequence&lt;br /&gt;  */&lt;br /&gt; public void insertIntoDb(String tableName,&lt;br /&gt;   int numValues,&lt;br /&gt;   ArrayList_of_String dataTypes,&lt;br /&gt;   ArrayList_of_String columnNames,&lt;br /&gt;   ArrayList_of_ArrayList_of_String values) {&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;One you have a list of column names, you can easuly concatenate them to form a string say,&lt;br /&gt;&lt;blockquote&gt;String col = "(col1, col2, col3)";&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Similarly, for values, using numValues, you can easily form a string say,&lt;br /&gt;&lt;blockquote&gt;String val = "(?, ?, ?)";&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Once this is done, make a query string like:&lt;br /&gt;&lt;blockquote&gt;String query = "insert into " + tableName + " " +  col + " values " + val + ";";&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;This will form a quert string similar to following:&lt;br /&gt;&lt;blockquote&gt;"insert into myTable (name, id) values (?, ?);"&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Then, write a loop which will iterate through the given ArrayList of values (actual records) and using &lt;a href="http://java.sun.com/j2se/1.4.2/docs/api/java/sql/PreparedStatement.html"&gt;PreparedStatement&lt;/a&gt; interface, fill in the values for '?' in the query string. Here you will use dataTypes provided; for example, if the corresponding data type is "string", write:&lt;br /&gt;&lt;blockquote&gt;cs.setString(index_of_corresponding_?, current);&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;else for "integer", write:&lt;br /&gt;&lt;blockquote&gt;cs.setInt(index_of_corresponding_?, Integer.parseInt(current));&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;where "current" is the current piece of text that you can get from ArrayList of records i.e. values.&lt;br /&gt;&lt;br /&gt;You can verify whether your final prepared statement is correctly built, using toString() method for PreparedStatement interface. It will show something like:&lt;br /&gt;&lt;blockquote&gt;"objectID1: insert into myTable (name, id) values ('abc', 1);"&lt;br /&gt;"objectID2: insert into myTable (name, id) values ('xyz', 2);"&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Then invoke executeQuery() method of the interface PreparedStatement which will actually insert these records in the table.&lt;br /&gt;&lt;br /&gt;Easy!! No? :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4425557513103987115-380997290818849758?l=non-non-sense.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/380997290818849758/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4425557513103987115&amp;postID=380997290818849758' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/380997290818849758'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/380997290818849758'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/2009/08/inserting-into-mysql-table-from-java.html' title='Inserting into mysql table from Java code'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4425557513103987115.post-3597383614621047917</id><published>2009-08-28T09:57:00.000-07:00</published><updated>2009-08-28T19:31:17.925-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='Data mining'/><category scheme='http://www.blogger.com/atom/ns#' term='coding tips and tricks'/><title type='text'>Select k records randomly from n records in Java</title><content type='html'>Assume a situation wherein you have an array of records, let them be anything varying from marks (integers), names (string), student information (user defined class object), or ANYTHING ARBITRARY which derives itself from Java's object. Suppose, you have such n records, each with an identifier say, 1 to n, such that you have then stored in array of any form in Java.&lt;br /&gt;&lt;br /&gt;Now, suppose you want to chose k random records from this array, this is how you proceed.&lt;br /&gt;&lt;br /&gt;Procedure:&lt;br /&gt;Given n, generate a random permutation of {1, 2, ... n} as {1', 2', ... , n'} and pick first k numbers from the permuted array.&lt;br /&gt;For example, say you want to pick 3 numbers randomly from 8, s.t. n = 8, k = 3.&lt;br /&gt;1. {1, ... 8} ===&gt; {2,3,1,7,6,4,8,5} ===&gt; {2,3,1}&lt;br /&gt;2. {1, ... 8} ===&gt; {8,4,3,1,6,5,7,2} ===&gt; {8,4,3}&lt;br /&gt;Thus, once you have k such indexes, you just need to probe your original array with these indexes and get corresponding k random records.&lt;br /&gt;&lt;br /&gt;The Java code snippet is as shown:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_iLEvmgkXNwE/SpgUy-n-PDI/AAAAAAAAAkI/3b2msfIsI1A/s1600-h/code_1.jpg"&gt;&lt;img style="cursor: pointer; width: 400px; height: 367px;" src="http://4.bp.blogspot.com/_iLEvmgkXNwE/SpgUy-n-PDI/AAAAAAAAAkI/3b2msfIsI1A/s400/code_1.jpg" alt="" id="BLOGGER_PHOTO_ID_5375069021303356466" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_iLEvmgkXNwE/SpgUtgd0SEI/AAAAAAAAAkA/Wn77T_Hp0gA/s1600-h/code_2.jpg"&gt;&lt;img style="cursor: pointer; width: 311px; height: 400px;" src="http://1.bp.blogspot.com/_iLEvmgkXNwE/SpgUtgd0SEI/AAAAAAAAAkA/Wn77T_Hp0gA/s400/code_2.jpg" alt="" id="BLOGGER_PHOTO_ID_5375068927308351554" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The output as expected is :&lt;br /&gt;&lt;blockquote&gt;randomly selecting 3 out of them&lt;br /&gt;1 a&lt;br /&gt;7 g&lt;br /&gt;5 e&lt;br /&gt;randomly selecting 5 out of them&lt;br /&gt;6 f&lt;br /&gt;5 e&lt;br /&gt;7 g&lt;br /&gt;8 h&lt;br /&gt;2 b&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I needed this for:&lt;br /&gt;I had to partition dataset containing some @1,000 records, for cross-validation. It is a method of training a classifier when you have small number of training records. In this, you will first decide how many folds of dataset you want to make, say 5-fold, then 1,000 records will be partitioned in the ration 4 : 1 such that every time 4/5 th of the data records will be used for training and remaining 1/5 th for testing (validating in this case). Thus, I needed to randomly pick 4/5 * 1000 of my records every time, for which I wrote above piece of code.&lt;br /&gt;&lt;br /&gt;Note 1: Not listing the code, but adding image so that, whoever wants to try it, will actually type in the things, and thus they will never forget the trick! :)&lt;br /&gt;Note 2: Reference - &lt;a href="http://http://www.cs.waikato.ac.nz/ml/weka/"&gt;Weka software&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4425557513103987115-3597383614621047917?l=non-non-sense.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/3597383614621047917/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4425557513103987115&amp;postID=3597383614621047917' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/3597383614621047917'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/3597383614621047917'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/2009/08/select-k-records-randomly-from-n.html' title='Select k records randomly from n records in Java'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_iLEvmgkXNwE/SpgUy-n-PDI/AAAAAAAAAkI/3b2msfIsI1A/s72-c/code_1.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4425557513103987115.post-5725819152185307022</id><published>2008-10-29T21:18:00.000-07:00</published><updated>2009-08-28T10:48:04.382-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Data mining'/><title type='text'>fundoo maths! in Data mining (ofcourse! ;))</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_iLEvmgkXNwE/SQk10_brg1I/AAAAAAAAAPg/HDQWySlqE-o/s1600-h/lda_2D.jpg"&gt;&lt;img style="cursor: pointer; width: 313px; height: 320px;" src="http://2.bp.blogspot.com/_iLEvmgkXNwE/SQk10_brg1I/AAAAAAAAAPg/HDQWySlqE-o/s320/lda_2D.jpg" alt="" id="BLOGGER_PHOTO_ID_5262796824056136530" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;See the figure above. Consider X-Y plane where some points are scattered and you are asked to find a separator between them. The black line going through the points separates them well. There is a significant property that such a line has, which is - linear separation. In the sense, the line is expressed as a "linear combination of X-Y co-ordinates".&lt;br /&gt;&lt;br /&gt;To understand this better, consider the figure below:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_iLEvmgkXNwE/SQk2YBMw08I/AAAAAAAAAPo/OGu86ti2UZI/s1600-h/2D.jpg"&gt;&lt;img style="cursor: pointer; width: 311px; height: 320px;" src="http://4.bp.blogspot.com/_iLEvmgkXNwE/SQk2YBMw08I/AAAAAAAAAPo/OGu86ti2UZI/s320/2D.jpg" alt="" id="BLOGGER_PHOTO_ID_5262797425825862594" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_iLEvmgkXNwE/SQk10_brg1I/AAAAAAAAAPg/HDQWySlqE-o/s1600-h/lda_2D.jpg"&gt;&lt;br /&gt;&lt;/a&gt;&lt;br /&gt;Can you separate these points (filled and not-filled red circles) by something which is a "linear separator"? If you consider to draw a line so as to separate these two types of point, you won't succeed. The reason being, the points are scattered such that no linear separator can separate them. Remember, by linear, I mean something (a line in 2D i.e. X-Y plane) which is expressible as a linear combination of its co-ordinates.&lt;br /&gt;&lt;br /&gt;In fact, the points above can be separated by a circular / elliptical shape as you might have noticed. A circle / ellipse could be drawn covering the not-filled i.e. hollow red circles in the middle and separating them from filled ones. But as one can argue, ellipse / circle is NOT A LINEAR SEPARATOR. For X-Y i.e. 2D plane, equation of circle is:-&lt;br /&gt;&lt;br /&gt;x^2 + Y ^2 = r ^2 ................. r being the radius&lt;br /&gt;&lt;br /&gt;and the same for ellipse is:-&lt;br /&gt;&lt;br /&gt;x^2 / a^2 + y^2 / b^2 = 1 .............. a and b being constants.&lt;br /&gt;&lt;br /&gt;these square terms make these shapes "non-linear" in nature.&lt;br /&gt;&lt;br /&gt;So, the Question is - Is there a way to separate these points by a linear separator?&lt;br /&gt;&lt;br /&gt;And the answer is as follows:&lt;br /&gt;&lt;br /&gt;Consider an added 3rd dimension to the above figure, say Z-axis. Imagine that we shift the hollow red circles behind along the Z-axis such that all of them are now in negative Z-axis region in 3D space. Now consider and plane parallel to X-Y plane such that it separates these negative Z-axis points from those with positive Z-coefficients. Such a plane now separates hollow and filled red circles well. See figure below for better understanding.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_iLEvmgkXNwE/SQk7v4gKwTI/AAAAAAAAAP4/qK1WvPkgqP0/s1600-h/lda_now_2D.jpg"&gt;&lt;img style="cursor: pointer; width: 309px; height: 320px;" src="http://1.bp.blogspot.com/_iLEvmgkXNwE/SQk7v4gKwTI/AAAAAAAAAP4/qK1WvPkgqP0/s320/lda_now_2D.jpg" alt="" id="BLOGGER_PHOTO_ID_5262803333366333746" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The important thing about such a plane is - It is now a linear separator. Because any 2D object, a plane here is a linear combination of its dimensions in 3D space.&lt;br /&gt;&lt;br /&gt;---------------------&lt;br /&gt;References:&lt;br /&gt;&lt;br /&gt;It is a major issue in classification, a topic in Data mining. Google for it. Keywords like "feature transformation, nonlinear separator / classifier" should help.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4425557513103987115-5725819152185307022?l=non-non-sense.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/5725819152185307022/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4425557513103987115&amp;postID=5725819152185307022' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/5725819152185307022'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/5725819152185307022'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/2008/10/see-figure-above.html' title='fundoo maths! in Data mining (ofcourse! ;))'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_iLEvmgkXNwE/SQk10_brg1I/AAAAAAAAAPg/HDQWySlqE-o/s72-c/lda_2D.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4425557513103987115.post-4784684818531154122</id><published>2008-01-25T02:32:00.000-08:00</published><updated>2009-08-28T10:48:28.803-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='health'/><title type='text'>Snoring</title><content type='html'>During lunch, my friend was telling about her roommate and was laughing on the fact that she snores. I also snore. Obviously I felt bad. She was indirectly laughing at me. Since childhood I have been observing my father snoring and always thought of finding out the reasons behind the same. I thought now is the time because I myself is facing the same problem. Google-d for some information and this is just the compilation of what I found.&lt;br /&gt;    Last few months, I have realized that I snore. I happens sometimes during deep sleep, sometimes just after I go to bed. Most of the time its winter or my throat has some problem, whenever i snore. Normally it happens that I myself awake after some time I have been snoring and then I realize that I was snoring. I also noticed that whenever I am awake after snoring, I am sleeping on my back. I have never noticed myself getting awake due to snoring, when I am sleeping on my side. All this made sense after I read Google-d results.&lt;br /&gt;    Main reasons of snoring are:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Throat weakness causing the throat to close during sleep&lt;/li&gt;&lt;li&gt;Mispositioned jaw, often caused by tension in muscles&lt;/li&gt;&lt;li&gt;Fat gathering in and around the throat (tonsil problems, may be)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Obstruction in the nasal passageway&lt;/li&gt;&lt;li&gt;Obesity&lt;/li&gt;&lt;/ol&gt;A very good article about snoring, its reasons and treatments can be found at &lt;a href="http://www.hinduonnet.com/thehindu/mag/2004/11/07/stories/2004110700350600.htm"&gt;http://www.hinduonnet.com/thehindu/mag/2004/11/07/stories/2004110700350600.htm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The reasons numbered 1 and 2 ask for sleeping at the side to prevent the tongue from blocking the throat. Thats the reason I notice myself awake after snoring when I am sleeping on my back more than when I am sleeping on my side. Reason 4 might focus on the case that during winter I notice myself snoring. Reason 5 is directly applicable to me!&lt;br /&gt;Reason 1, 2 and 5 are applicable to my father as well, who snores.&lt;br /&gt;&lt;br /&gt;As known effects of snoring can be told as restlessness, hypertension (which may lead to heart-attack in very few cases), increased day time sleep, depression. (I go through almost all of these!)&lt;br /&gt;&lt;br /&gt;A huge and useful information can also be found at my favorite wikipedia..&lt;a href="http://en.wikipedia.org/wiki/Snoring"&gt;  http://en.wikipedia.org/wiki/Snoring&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As said in Hindu article,&lt;span style="font-weight: bold;"&gt; Snoring is no longer a laughing matter. It may lead to serious disease.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4425557513103987115-4784684818531154122?l=non-non-sense.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/4784684818531154122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4425557513103987115&amp;postID=4784684818531154122' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/4784684818531154122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/4784684818531154122'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/2008/01/snoring.html' title='Snoring'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4425557513103987115.post-4414467927242543516</id><published>2008-01-16T05:26:00.000-08:00</published><updated>2009-08-28T10:48:53.140-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='economics'/><category scheme='http://www.blogger.com/atom/ns#' term='general'/><title type='text'>carbon trading</title><content type='html'>I had heard this term.. of course without knowing the meaning.. During "Applied Economics" (!!) lecture, Sir explained it.. As follows:&lt;br /&gt;&lt;br /&gt;Lets assume for a certain area, air pollution restrictions are laid.. in a sense.. no factory should emit (say) 100 units of carbon (carbon- in a sense, pollution causing element). Lets say in that area, there are 2 companies A and B.. A's factory is controlling its emission to say 80 units of carbon.. Then they are given a sort of "carbon saver" certificate, indication of "they are carbon savers" That certificate is considered of having a value. Because, if suppose company B's factory is not able to control their emission to 100, say they emit 120 amount of carbon.. they can acquire (may be, actually BUY) this "carbon saver" certificate from company A!! sort of license.. to emit higher amount of carbon.. So that total level of carbon in that area is kept constant (120 + 80) as well as because company A has saved carbon, they are given reward while company B which could not save carbon, is - in a sense - penalized.&lt;br /&gt;&lt;br /&gt;Cool information.. isn't it?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4425557513103987115-4414467927242543516?l=non-non-sense.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://non-non-sense.blogspot.com/feeds/4414467927242543516/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=4425557513103987115&amp;postID=4414467927242543516' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/4414467927242543516'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4425557513103987115/posts/default/4414467927242543516'/><link rel='alternate' type='text/html' href='http://non-non-sense.blogspot.com/2008/01/carbon-trading.html' title='carbon trading'/><author><name>Girija</name><uri>http://www.blogger.com/profile/06904019980664523275</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://4.bp.blogspot.com/_iLEvmgkXNwE/TA8qE70XDxI/AAAAAAAAA6w/EYxcBDw9rlg/S220/girija_lake.jpg'/></author><thr:total>0</thr:total></entry></feed>
