Wednesday, November 2, 2011

gitk on MAC

I had trouble getting gitk to work on my mac. It did not do anything and did not throw an error as well. After reading through some forums I found that the PATH variable is the culprit. In my .profile ( or in .bashrc), wherever you set PATH variable I had set it the following way:

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

I modified it to the following:


export PATH=$PATH:/opt/local/bin:/opt/local/sbin

and everything works fine now. Hopefully someone with similar issues will land up on this page.

Thursday, July 28, 2011

Debian changing root password

Follow these instructions to boot into single user mode and change the password of root on Debian.

1) When GRUB loads press 'e'
2) Find the line with initrd and goto the end and add init=/bin/sh
3) Press Ctrl + x to boot
4) You will get a prompt with #
5) You need to remount the root filesystem in read write mode by using the command mount -o remount rw /
6) use the command passwd to set the new password.

Done!

Saturday, July 9, 2011

Statistics is FUN!

This summer I am taking a basic statistics course and auditing an advanced one. If the basic one is increasing my knowledge and giving me the confidence the advanced one is killing me!(in a very very good way!) After a very long time have I have had to spend nights understanding things from various textbooks and the joy in doing it is awesome! I am writing this post to share few thoughts and resources related to the topic.

1) In the past many of my friends have asked me for soft copies of ebooks. I download most of them from the following site: http://library.nu
I found almost 90% of the textbooks & novels I searched for from this website. I am using the following four statistics books to keep myself busy! Each book uses a different notation which gets to me more often than not but as of now the patience is paying off.
a) Probability & Statistics by Athanasios Paupoulis
b) Probability & Statistics in Engineering by Hines et. al.
c) Theory and problems of probability & statistics by Schaum series
d) All of statistics by Weisserman

2) I hate calculating expecation, covariance and correlation and all that crap for discrete distributions. Firstly, the calculations are cumbersome and secondly I hate Algebra! So, I put together the following script that calculates these. Just update the pdf and x, y vectors and you will get all the answers you need.

pdf=[11/50, 4/50, 2/50, 1/50, 1/50, 1/50;
8/50, 3/50, 2/50, 1/50, 1/50, 0;
4/50, 3/50, 2/50, 1/50, 0, 0;
3/50, 1/50, 0, 0, 0, 0;
1/50, 0, 0, 0, 0, 0;]
x = [0:5]
y = [0:4]

fx = sum(pdf)
fy = sum(pdf,2)'
ex = sum(x.*fx)
ex2 = sum(x.*x.*fx)
varx = ex2 - ex*ex
ey = sum(y.*fy)
ey2 = sum(y.*y.*fy)
vary = ey2 - ey*ey
[xgrid ygrid] = meshgrid(x,y)
exy = sum(sum(xgrid.*ygrid.*pdf))
covxy = exy - ex*ey
corr = covxy/(sqrt(varx)*sqrt(vary))

3) Proofs have always intrigued me. Although there is lot of fun in using a formula to get the answer and feel satisfied, I always found real satisfaction in deriving the formula. Being a computer science major has deprived me of such opportunities. But thanks to the stats course I get to sit and prove stuff again :-)
I am sharing two of the proofs for which I did not find straightforward solutions online. I hope it helps others who are trying to understand the proofs.

Sunday, June 26, 2011

Probability Distributions

I am playing around with various discrete and continuous distributions for a statistics course assignment. So, I thought of spending few extra minutes and make a matlab script that would plot all of these. Below is the simple matlab script that plots Uniform, Exponential, Normal distributions. The Normal distribution can be generated using inverse transform, box-muller method and the most famous theorem in statistics: The Central Limit theorem.

I want to extend the script to take various parameters and plot more distributions like weibull, poisson etc. but I dont have time right now!



Code:

%% Uniform distribution using 100 instances
u1 = rand(1,100);


%% Uniform distribution using 1000 instances
u2 = rand(1,1000);

%% Exponential distribution using 100 instances
e1 = -log(u1);

%% Exponential distribution using 1000 instances
e2 = -log(u2);

%% Normal distribution using inverse transform method
n1 = norminv(u2,0,1);

%% Normal distribution using box-muller method
n2 = sqrt(-2*log(rand(1,1000))).*cos(2*pi*rand(1,1000));

%% PLOT1 ( Uniform, Exponential, Normal distributions )
figure(1),subplot(3,2,1),hist(u1,10),title('Uniform using 100 instances');
figure(1),subplot(3,2,2),hist(u2,10),title('Uniform using 1000 instances');
figure(1),subplot(3,2,3),hist(e1,10),title('Exponential using 100 instances');
figure(1),subplot(3,2,4),hist(e2,10),title('Exponential using 1000 instances');
figure(1),subplot(3,2,5),hist(n1,10),title('Normal using inverse transform method');
figure(1),subplot(3,2,6),hist(n2,10),title('Normal using Box-Muller method');

%% Triangular distribution
t1 = rand(1,1000);
t2 = rand(1,1000);
t3 = t1 + t2;

%% Central Limit Theorem
n = 12;
for i = 1:n
    t(i,:) = rand(1,1000);
end
n3 = sum(t);

%% PLOT2 ( Trinagular and Normal distributions )
figure(2),subplot(1,2,1),hist(t3),title('Traingular distribution');
figure(2),subplot(1,2,2),hist(n3),title('Normal using central limit theorem');

%% Save to eps files
figure(1),print('-deps','1.eps');
figure(2),print('-deps','2.eps');

Thursday, April 28, 2011

Easiest & Fastest way to save Kinect depth and image data

After searching a lot to quickly get range and intensity data I thought of documenting the best way so that other people save their precious time! 

I ended up using Mobile Robotics Programming Toolkit(MRPT). Please goto this page for installation instructions: http://www.mrpt.org/Kinect_and_MRPT
I used the option of "installation from the repositories" instead of compiling from source. Its fast and easy this way.

Once that is done,
Download the code from here: Code
Download the cmake file from here: CMakeFile

Commands:
cmake .
make
sudo ./kinect_view

Saturday, March 5, 2011

Cannot find the library `/usr/lib/libgdk_pixbuf-2.0.la`

I got this error while compiling Peekabot from source. If you get this error for the same reason or for any other reason: Installing pixbuf from source package is the workaround for now.

apt-get source libgdk-pixbuf2.0-0
cd gdk-pixbuf-2.22.0/
./configure --prefix=/usr
make
make install

If you install from the repos you get the shared library but not the static which peekabot seems to require!! 

Good luck!

Friday, February 11, 2011

Theory cheat sheet

For the theory course(CS6505- Computability, Algorithms, and Complexity) at Gatech I along with couple of my friends prepared a cheat sheet covering the topics of NFA, Turning Machines, Turing Reducibility, Data structures( Fibonacci Heaps ), Algorithms ( Dynamic programming, Divide and Conquer, Matching algorithms etc. I am sharing the .tex and pdf file in case its useful for someone. Please feel free to download and modify for your use.

 TEX & PDF

Tuesday, January 18, 2011

.glc to .avi conversion script



Thanks to Jon Rogers for this script!


#!/bin/bash
FILES="*.glc"
for f in $FILES
do
 echo "Processing $f file..."
 # take action on each file. $f store current file name
 glc-play $f -y 1 -o - | mencoder -demuxer y4m - -ovc lavc -lavcopts vcodec=mpeg4 -o ${f%.*}.avi
 # This previous line takes in the glc file at $f and changes the extension to .avi for saving it as mpeg4

done

Saturday, January 15, 2011

Combining two laser scans into one coordinate system

For my current Boeing project I have to use two laser scanners to get 360 degree fov. I need to extract walls from the room and localize based on the walls. I decided to combine the laser scans from both lasers into one coordiante system and then extract walls. I wrote few matlab scripts to combine the scans and extract lines etc. After being satisfied with the results I moved to implement the same in C++ specifically in ROS. When I reimplemented I got very weird results when I combined both laser scans into one coordinate system.

After debugging for almost a day and taking help from a friend I found the BUG! I wish it was a programming bug, sadly it was a mistake in my understanding. I tried to put as much as possible in the image below. Once we knew the problem the formulas were elementary math but realizing that we needed to do this took time. I partially blame my matlab implementation which was also wrong but the error was never noticeable in the plots! At the end of the day though, things are looking great and I am glad one bridge is crossed :-)



After implementing it, the program started crashing arbitrarily giving segmentation fault! And that lead us to another "double precision" issue!! The calculation involves taking inverse sin by using asin. asin gives a HUGE number for any input greater than 1. In case of asin(a/b) for a=b due to double precision problems the function returned a crappy number. So, I had to make a minor modification so that a is always less than b :-) A productive day involving lot of debugging and learning!