Few Mathematics Jokes

[JOKE1]

A physicist, a biologist, and a mathematician are sitting on a bench across from a house. They watch as two people go into the house, and then a little later, three people walk out.
The physicist says, “The initial measurement was incorrect.”
The biologist says, “They must have reproduced.”
And the mathematician says, “If exactly one person enters that house, it will be empty.”

[JOKE2]

Infinitely many mathematicians walk into a bar. The first says, “I’ll have a beer.” The second says, “I’ll have half a beer.” The third says, “I’ll have a quarter of a beer.” The barman pulls out just two beers. The mathematicians are all like, “That’s all you’re giving us? How drunk do you expect us to get on that?” The bartender says, “Come on guys. Know your limits.”

Explanation: This is a reference to a converging infinite series.
The limit of this:
from n=0 to ∞ Σ (1/2n) = 1 + 1/2 + 1/4 + 1/8 + … = 2

[JOKE3]

An infinite number of mathematicians walk into a bar. The first one orders a beer. The second orders half a beer. The third orders a third of a beer. The bartender bellows, “Get the hell out of here, are you trying to ruin me?”

Explanation: This is another hilarious reference to an infinite series — the harmonic series — which is not convergent but instead diverges to infinity.
from n=1 to ∞ Σ (1/n) = 1 + 1/2 + 1/3 + 1/4 + … = ∞

[JOKE4]

When a statistician passes the airport security check, they discover a bomb in his bag. He explains. “Statistics shows that the probability of a bomb being on an airplane is 1/1000. However, the chance that there are two bombs at one plane is 1/1000000. So, I am much safer…”

Explanation: While this statistician is correct that the joint probability there are two bombs on a plane is 1/1,000,000, his bringing one on doesn’t change the prior probability that there is still a 1/1,000 chance of his flight being the one with a random bomb.

[JOKE5]

Write the expression for the volume of a thick crust pizza with height “a” and radius “z”.
Explanation: The formula for volume is π · (radius)2 ·( height). In this case, pi · z ·z ·a.

[JOKE6]

Three statisticians go out hunting together. After a while they spot a solitary rabbit. The first statistician takes aim and overshoots. The second aims and undershoots. The third shouts out “We got him!”

[JOKE7]

Two random variables were talking in a bar. They thought they were being discrete but I heard their chatter continuously .

Explanation: When you roll a die, you either get a 1, 2, 3, 4, 5, or 6. Since there are a finite number of possibilities, the statistic involved is called a discrete random variable. When you select any real number from between 0 and 1, there are an infinite number of possible draws. The statistic involved is called a continuous random variable.

Bus Ride of Engineers

Well, I could not resist writing about this very normal, day-to-day life activity at my work place. There are branches of quite a few organizations including Cognizant, IBM, Philips, Siemens inside MEBP(Manyata Embassy Business Park), Bangalore. Given the big area of MEBP, a walk from MEBP gate to the office seems really troublesome to many of the employees. Considering the physical effectiveness and mental state of engineers, MEBP runs few shuttle buses which starts from MEBP gate and make few stops on its way back to the same gate. Now here is the scenario: Its 9 o’clock in the morning. The shuttle bus is moving close to the MEBP gate to start its journey. At the bus stop, around 30 to 40 people are waiting for the bus, though, there are seats only for seven people inside and some room for around 10 people to stand. Few people start running alongside the bus but slow down eventually due to the already awaiting crowd. At the moment, everyone is putting their innovative thoughts on how to get to the gate of the bus first which has still to open. Slowly, the bus stops and the bus door opens providing a small portal(really, it looks like a portal at that moment) to get inside the bus, wide enough for one person to get in. With this the fun begins. obviously, there is no queue and every one is following “Every man for himself” policy. Most of the people there have only one goal, get inside the bus through that small portal hardly worrying whom they are pushing aside to make their way. It seems like a wrestling show with wrestlers in well ironed formal dresses having laptop bags in their hands, probably using it as a weapon. It’s not over yet. Now comes the shepherd, I mean a security personnel. He peeps in through the window of the tightly packed bus and shouts, “Sir move inside sir”, though there is hardly any. He keeps on doing this, irrespective of the space inside the bus till the bus leaves. The bus driver enjoying the whole show ensures that the bus can not accommodate any more. Once assured, he slowly starts the bus to begin the grand journey. Interestingly, it’s not just 9 o’clock when this scenario can be viewed. It’s not very pleasing to see bright Indian brains(now com’on, they are engineers of India) behaving in such a manner.

Gruyere

Just went through gruyere, a great place to learn basics of web security. It provides a platform where we can have hands on experience on different vulnerabilities. It not only provides the exploits but also the solutions to it. One of the good things about it is, for any challenge it doesn’t reveal the complete solution at a time. The solution is divided in parts, in form of hints i.e. first hint then another and likewise. It makes you think over the challenge at different levels. Though it doesn’t cover sql-injection as gruyere doesn’t use SQL. Also, buffer and integer overflows are missing due to use of Python. Python doesn’t allow buffer and integer overflow. Altogether, it gives a very good overview of different web security vulnerabilities. This video gives more real time examples of different vulnerabilities.

*args, **kwargs

Not to mention Stack Overflow is amazing. If you haven't joined it, do
it asap. It's really helpful to get you through major/minor programing 
issues. Now, for example this one question I found interesting and hope
would also interest the python beginners specially. Have you ever 
wondered what do you use *args and **kwargs for, as in function:

def myfunction(*args, **kwargs):
    # some stuff

Well, in short *args are used for passing arbitrary number of arguments
to your function, specially in the cases when you are not sure how many
arguments you gonna pass in the function. Take an example for *args 
first:

def myfunction(*args):
    for i in args:
        print i

myfunction([1,2,3,4,5], 2, 6, 'Hello', {'q':'2'})

output:

    [1, 2, 3, 4, 5]
    2
    6
    Hello
    {'q': '2'}

The above example just prints the contents of args.

**kwargs are used for passing named arguments as in example:

    def myfunction(**kwargs):
        for i,j in kwargs.items():
            print i, '=', j

    myfunction(name = 'Naruto', profession = 'Ninja')

output:

    profession = Ninja
    name = Naruto

The above example prints the items in kwargs. 
The names 'args' and 'kwargs' are not cumpolsory but just part of naming
conventions.

Mercurial Queues

While using mercurial as a version control system, often we come across the problem of incorrect commits. A while ago I came across Mercurial Queues(mq) which I found very helpful in managing our changes. We can remove or add changes anywhere in the change sets, with a few conditions which I’ll mention later in this post.
There is no need to download mq, you just need to enable it in your system. To do that go to your ~/.hgrc and add the following contents to it:

[extensions]
hgext.mq =

That’s it, mq is enabled in your system. Now let’s have a look at it’s usage. An example may help in getting a better idea. Say there are 4 change sets namely 0, 1, ,2, 3, 4. Now you want to delete change set 2.

1. Initialize mq using:

> hg qinit

2. Now you need to import the changes to mq. As change set 2 need to be deleted here, import change set ‘2’ to the mq using:

> hg qimport -r 2:tip

Here we import all the changes from revision ‘2’ to tip because change sets after revision ‘2’ are the children of revision ‘2’.

3. Now first pop the the changeset with revision ‘2’ and then delete it. You can also use ‘hg qseries ‘ to view all the imported change sets.

> hg qseries

  • 2.diff
  • 3.diff
  • 4.diff

> hg qpop 2.diff

  • popping 4.diff
  • popping 3.diff
  • now at: 2.diff
> hg qpop
  • popping 2.diff
  • patch queue now empty

> hg qdelete 2.diff

Now push the changes back to the mq:

> hg qpush 4.diff

  • applying 3.diff
  • applying 4.diff
  • now at: 4.diff
Now, 2.diff is out of change sets. We are almost done now. Now the last step is to add these ‘diffs’ to the working change sets.
> hg qfinish 2
> hg finish 3
As I have said there are certain constrains to the above method or mq.
  1. There should be no merges or merge commits in between the tip and the change set you wanna delete.
  2. All the changes set should be clean and must not depend on each other. Say for example you created file ‘myfile’ in revision ‘2’ and added some contents to it in revision ‘3’. That would create failures while pushing the changes again.
Though the process seems little big and messy, would help a lot once you get used to it.

tests: pytest-2

MoinMoin is a wiki engine written in Python. Many well known organizations are the users of MoinMoin which includes Ubuntu, Python, Debian, Mercurial etc. More about MoinMoin can be viewed here.
It is well known that there is always a need of development even in most smart softwares, MoinMoin is not an exception. One of the fields of development is ‘Testing’. Currently, MoinMoin uses ‘py.test 1.3.4’ for testing. Also, there are some major issues with the current testing framework. So, this year in GSoC, an idea was introduced to refine the whole testing framework of MoinMoin including reimplementation of Tests for pytest 2.0. I too, submitted a proposal for this project and fortunately it got selected. It is important that the implementation should be less ad-hoc and more dynamic. Also, it should support future development i.e we should not be working again and again with each new modification in MoinMoin dependencies.

Porting of ‘Packaging’

Distutils2 is an improved version of the Python Distribution Utilities, a library used to package, distribute, build and install Python projects. Unfortunately, distutils2 was available only for python 2.x and hence, many attempts continued to try and to port it over to python 3.x. Though, we have ‘2to3’, a utility to convert python2 codes to python3, it has its limitations. So, finally this year in pycon i.e. pycon 2011, during a sprint on distutils2, distutils2 was ported over to python 3.3 and its name was changed to ‘Packaging’. Thanks to all the contributers, many major changes and improvements were introduced to distutils2 or let’s say packaging which includes removal of ‘_backport’. All the major and minor changesets are available at tarek/repo.

There are several tasks on the Todo List of cpython/wiki and back-porting ‘Packaging’ to other versions of python i.e. python 2.4 to python 3.2 is one of them. In my opinion, it will be a good idea to backport ‘packaging’ rather than porting distutils2 over to python 3.x, knowing that many python 3.x releases are yet to come. This task has been introduced as a GSoC project for this year and is being mentored by Tarek Ziadé.  This project is more about providing a tool or mechanism for the porting of packaging over to other specified versions(2.4 – 3.2) of python than just porting the current code. It is important that on completion of this project, we should not be working on porting work again and again with every new modification in the ‘packaging’. Just some minor changes in the tools or fixers should be enough, so that this tool can easily be updated over time.

One of the good things about softwares is that it can always be improved. Being a part of development process of packaging, cpython/wiki is a good place to visit to find issues and current progress of packaging.

Naruto

Read Naruto manga yesterday. Finally, Naruto is entering in the war. I guess, the war was getting little boring and draggy with all new the characters. Seems like its going to be interesting.

Placements contd….

I and my friends are still wondering about the recruitment process of Wipro. A package of 2.75, a bond of 15 months where we need to pay 75000 as a security money. But when you see the recruiting process, it was one among the toughest. First of all there was a written test consisting of aptitude and technical test. After that there is a technical interview where your technical ability is tested. Its not over yet. Candidates have to go through the HR interview. On the other hand if we talk about Infosys and CTS who are giving a package higher than Wipro had a single interview and correspondingly simpler test paper. Also, CTS has no bond and Infosys is providing an internship to the selected candidates, which in my opinion is more favorable to the students.

Placements

2 days back I attended the placements of INFOSYS and CTS. Presentations given by Infosys was quite impressive. People do talk about tough and rigorous training in Infosys but I feel that it is worth for the knowledge you gain. Package being provided by INFOSYS is 3.25 lacks and you can also have an internship for the last semester of your graduation.
The presentation of CTS was a bit more formal which didn’t seem interesting to some of my friends. Package provided is 3.05 lacks. The good part is there is no bond for this company.