Sunday, September 02, 2018

Monty Hall Problem

Today I want to talk about a game show that used to come to Star Plus, "Khullja Sim Sim". If I remember correctly, Aman Verma was the host. I just used to watch without understanding much.

During college, I read about the Monty Hall problem and it was so counter-intuitive, I could not believe it and thought of it as just a theoretical analysis and the real life situation would still be same for both the situation. Later, I forgot about it.

Very recently, I again read about it and I remembered that I was skeptical about it the last time. But, now I could write code.

So, I wrote a code which randomly puts prize in one of the three doors. Then, the player has a random first guess. The game then opens an empty gate and the player is given a chance to change his earlier choice. I tracked number of wins separately for both the situations when the player changes their first choice and when they do not.

Surprisingly (for me, not for those who understood the analysis properly), the result is better when the player chose to change their first choices. Double, to be precise.

The analysis loosely translates to the fact that, if you do not change your choice, your probability still remains 1/3 whereas, if you select, it becomes 1/2 since the second time, only two options left.

I understood the argument properly even the first time. But, did not realise how deeply the concept of probability is entangled with our day-to-day situations. It was overwhelming for me and I wanted to share this with all of you.

You can find the code here. Do let me know what do you think about the problem.

Wednesday, June 27, 2018

Something About Professional Growth

I have done job search very recently and a few years back to extend the career horizons. This post is not to provide tips, but to share one realisation that I have gone through in the process.

What happened a lot of times with me is that, it seemed to me that I would be a perfect fit for a role me interview would go well and I would be sure that the people at the other end of discussion loved me. But, then I would get a regret mail. Whereas, I would get green signal response for roles which would not match my exact past experience. I used to be flabbergasted.

But not anymore. What I realised is that when a potential employer look at your past experience, they are trying to assess you based your past achievements and determine how you take challenging situations. Most of the time they are not looking for exact matches. Of course, for very specific roles, this is not true. But, this holds good for most of the situations.

What they want most of the time is that you have a room to grow. If you are an exact fit, you would become bored very easily (unless you have home loans).

I believe this is a good thing. Variety and diversity always help. Maintaining diverse anything is helpful when things start going south, and you would not realise about problematic nature ofmonoculture when things are good. I personally believe even a very technical role needs certain room to grow.

Something to think about when you do not hear positively from a potential employer for a role that exactly matches your past experiences.

Saturday, June 23, 2018

Preliminary Monte-Carlo to Find Value of Pi

This may be called Monte Carlo, but, I do not think it is a good example. Nevertheless, let us try to see. This is a product of a situation when you do not have much left to watch on Netflix.

The idea is to use the pseudo random number generator in C to get random points inside a square of sides with length 2 units. We shall try to determine if a point is lying inside the circle that is inscribed inside it. If random numbers are well spread, then ratio of number of points inside the circle to the number of points inside the square should be equal to that their respective areas.

Apart from the usual stuffs, one thing to note is that the pseudo random number generator in C is not thread-safe. The seed gets locked and its state gets changed in usual rand() call. GCC kindly provides this thread-safe version of it (rand_r()). Otherwise, with multi-threading, run-time actually increases.

Another minor thing is that since the pseudo-random numbers generation is mostly similar time consuming, default OpenMP for option (static) is best fit.

This is a plot of percentage error vs number of iteration. Probably due to pseudo part of the random numbers, we might not ever reach very close to the real value as we increase number of iteration most of the time.

You can find the code here. Please let me know your comments.

Wednesday, May 04, 2016

About fever, life and thermodynamics

  I recently had a very bad fever. One which lasted about two weeks. The thing that do not like about fever the most is that it happens in one day but fades away gradually. So, you start feeling bad from feeling good in less than one day. But, you do not get well suddenly! You do not get the feeling of being well too quickly. That is what I do not like about fevers.


  Thinking about it, what I realise is that this is of course true in every aspect of life. If we let everything to be on their own device, things will become more and more chaotic and it takes quite some effort to make things orderly. That too, will happen gradually.


  We had a chemistry teacher in our school, who tried teaching us about thermodynamics, entropy and chaos. Well, he mostly wasted his and our times. But, he said something that is still in my head. He said that, life is thermodynamically infavourable process. So, it takes effort to keep life going. I think it is true for all the aspects of life in general. It needs just one infection to get you a fever, one small disagreement to break off a relationship, one small mistake to let go of an opportunity of a lifetime.


  There is one quote often attributed to famous Indian statistician P. C. Mahalanobis. I am not sure about its authenticity, but it says, disease is contagious, health is not. It takes very little effort to go towards disorderliness, but a lot to keep it as you want something to be.

Saturday, January 19, 2013

Identify, Recognise, Remember and Value

  We all remember the candy that was refused by our moms. I used to be very angry and annoyed with these instants. I used to wonder why exactly she was refusing to let me have a candy. As a kid, I wondered if she was having candies behind me and not letting me have some of them.

  After I grew up a bit, I understood I only remembered the times she refused and not the times when she allowed me to have some candies. I understood that she was doing this for my own god. She was stopping me from having candies more than certain limit as having many of them might not be good. I also understood that she did bar me from many activities beyond a certain limit as it might have had the some bad effect on me.

  Then my age increased some more. I found that some people in my life is actually barring me from doing certain things. For those who don't personally know me, I am a bit slow in noticing and understanding everything. I thought they were being selfish and trying to not let me have fun in my life. And many times, not always, I went on doing those things they asked me not to do.

  Most often what happened is that I somehow either felt bad, got hurt, or had materialistic loss; not always of course. I thought about it. I understood that there are few people in my life who want the very best for me. As they are not me, they can observe and understand my life objectively which is very hard for me to do as my life is my own. Of course, they understood me only that much, till the point I allowed them.

  I believe all of us have that set of few people in their lives those who want the very best for them. We need to identify and remember them. We need to understand their words from a futuristic point of view keeping in mind they want only good for you. We need not always refuse the ideas which may cause not to have immediate material/emotional displeasure. We need to value these people's opinion. And in a world like this, which is mostly selfish, we need to value these people too.

Thursday, August 30, 2012

Crossroad In The Way Of Understanding People


In life you come across many crossroads. They are of many categories. They will make you think and decide about the issues. But what if the crossrads are coming in the process of decission making itself.

I always tried to find answers, rather explanations to everything that is happening around me. It always irritates me not to have the explanations. Sometimes I even pay a very big price to have very little knowledge about something that is concerning me and consider as my gain even though in general notion it does not seem so.

So it is of no wonder that I will always try to get the explanations of any given situation or anything that is happening to me.

No matter how hard you try, you end up expecting in every sphere of life. As of now, without practice of meditation or something similar, you are bound to have lost control of your desires. So in our lifestyles, expectations are inevitable. But what are the consequences?

You expect something. That means there is atleast 50% of chance that you will not get that. atleast because, most of the case, expectations are supposed to be fulfilled by a person  who is NOT you.

What if you expect something, and then not given. Then a situation comes where you cannot have that soemthing and now the people, who are supposed to fulfil your expectation when there was a chance, starts saying how they want to fulfil them and cannot do now only because situation does not give them any chance. When just maybe two days ago situation was favourable and they just ignored it.

Again something like this also may happen that there might be a chance that situation might turn favourable again. First they be sure that the situation is not going to turn in favourable. Then they will say had it been that way, they could have done this and that.

All I want to say that I am now growing up. Although it is very late, but I am happy that I know tomorrow when I shall be going to bed, I will be more mature than today. I learnt many things about life in very hursh ways as I was late. So I am going to believe whatever I understand instead of what I am told. Because only your thinking process and views will remain with you till the end. Anyway, people believe whatever they want to believe. This also is my observation. So as a part of growing up, I shall also go by this rule.

But on the same note I know this also, that I will not stop believing in people. That is the last thing one should do. But what you will believe about them is choice that left to you by the Matrix.. :P
I will take the crossroads that suits me. I guess that is what everybody does.

Sunday, July 08, 2012

Be Careful What You Wish For

I am a very big fan of Dr. House. He sometimes says "you can't always get what you want." I also believed that, until very recently. As you cannot get what you want immediately, this might seem true for some time. Some of my experiences made me think in other ways.


I saw this documentary "Law of Attraction" (not the movie) almost three years ago. It says right attitude of having something already accomplished which is not accomplished yet, will actually help you to reach that destination. Of course it sounds absurd at first. But I believed that positive attitude is thousand times better than a negative one.


Also in a conversation around two and a half years back, one of my friend Anton asked me if at the back of my mind I am still interested in physics or not. I was not doing well in my studies. It made me think that whatever idea you dump on the back of your mind, you consciously may forget it. But it stays there and dictates all your future actions. They can as well be analysed very strongly from that point of view.


Observations show that apparently strong dams built on rivers are required regular maintenance. Though the calculated shock that can absorbed without any damage is more than the actual force the river exerts for a given amount of time. Similarly, it may be inferred shows that if you continuously let something stay at the back of your head, it affects your action in achieving or fulfilling those ideas.


That is why I realised that whatever you want, make sure you want it in the long run. Because if it is not, you might not like it when you get it. But nothing can be done then as everybody would know what you were up to all these times and all the situations created were already very strong to not let go off the thing you wanted all these years due to your actions. So, I think it would be wise to decide beforehand what you really want instead of not liking it that much later. Be careful what you wish for, it might come true.

Sunday, July 01, 2012

Human Nature: As I Found It


As I am trying to live my life rather than merely existing as mention in many great people's quotes, I keep coming across many astonishing revelations about human nature. Since our interactions and involvements are mostly with another human (well if not really, virtually), that is what continues to intrigue me.


I had a habbit of reading classic novels and short stories and also old English poems (mostly of romantic age). My father being a English literature student, I had relatively easier access to these classics. I read many words at one can say an unprepared age. Some of them, if I am lucky enough to find a correlation with something in real life striked me very hard. Some of them did not.


I somehow always restrained myself from learning about human nature through human interactions as most of the time I used to find this action inseparable from judging people by their actions. Well, until very recently. I realised that probably it is necessary for living comfortably, for not getting hurt agian and again.


So, now that I have decided to start learning from first hand human interactions, I started realising that almost all words in them have a significance. So, I may realise something new today, but when I think about it, it is very much normal to the world already.


One of the lessons that recently I learnt about human nature is that people will do whatever they feel important anyway and find and excuse to not do whatever they feel is not important. This is true everytime. No matter what your relation is with that person, be it your parents, best friend, teacher, that special someone or even your admirer. It does not matter what prejudice you have about them or what you expect them to do. And no matter how much important you think something is, if another human does not think it is, my experience says better expect him to do the opposite. Less disappointment for you.


But in the end, it's all good I think. Life, after all is just a ride. People with different point of view will keep coming and neither you can always avoid them, nor it's worth the effort. I think enjoying the ride is all that matters.

Monday, April 16, 2012

Truth, Knowledge and Realisations

I always used to have this unquenchable thirst for knowledge. About everything. I always wanted to know the truth. What exactly is going on behind the scene, everywhere, what is the impact of my words or deeds; how exactly it is affecting the world. As I grew up with a mentality like this, mostly I remain truthful to people (with a few exceptions of not telling my parents about going out with a girl or that my geography marks for the sessional came out and I could not obtain the pass marks :P). And somehow in turn expecting the people to be truthful to me too. I always appreciated if they let me know what exactly they think of me and if some problem arises I preferred talking about it point blank.

As I became involved in this world more and more, I went through many realisations, mostly cyclic. Nevertheless I still was eager to know what is always going on behind the scene. One thing I always believed truly that the truth can and shall set me free, free from this vicious cycles of realisations. It always gave me the opportunity to come out of an incident and look into the matter objectively, needless to say which everytime helped me even if there was no apparent problem.

But as I became somewhat more involved with the people of this world, I came to realise that it may not be always wise to dig to depth to bring out the truth. The very reason that you have to dig deeply, is also the reason of the violence once the truth comes out and somehow suddenly it does not matter anymore to anybody except yourself. To be very frank, what I have realised, people will behave in whatever way they want to behave, no matter what they told you before and in the process of knowing the truth you also come across the falseness of their words. Somehow it made me feel that the truth may only matter to a few people and for the rest, is whatever make them feel better.

In this process, I also came to know that I may not like the truth. But that never told upon my strong desire of making the truth come out. What did was my own action also along with others' participation after I made the truth come out from them. Though I heard this many times that it certainly is not wise to know the truth every time, I am not sure about the credibility of the words. Even when I realise that the truth may make things worse, may make me feel worse, I still have this splinter of desire in my mind to know the truth.

Saturday, March 31, 2012

“There is no friend as loyal as a book” ― Ernest Hemingway

I started liking books since my childhood, same for most of the people I guess. I used to read them over and over and so never ran out of books to read. This compelled my mother to hide the books during my exam time as I used to perform poorly. I remember sometimes I could discover where she hid them and its feeling was similar to climbing a tough peak.

Then I grew up (my age increased). I started finding my hiding place inside them. To be very frank, I am a dull human being. I sometimes fail to tune with the outside world. So, for my peace of mind I learnt to turn to them whenever I feel lonely. It never disappointed me.

I came to college. I became exposed to many aspects of life which I did not know of. I became aware of incompleteness of life and the necessity of it. And I dived into the so-called ocean of life.

At first I couldn't enjoy. I thought its because I was learning how to swim.

Many days went by. Few moments of joy, some heartbreakings and a lot of indifference happened to me. And now at the end of it, as I am trying to evaluate what I was doing in this ocean, I realised that what I learnt is simply how to dance at the small waves and avoiding the larger ones. What it felt to me was something similar to a subject, student of which can either perform as a general graduate or can teach that subject to produce similar students.

Now once again, I looked back at the books. Whenever I get unfulfilment from this 'real' world, I turned back to it. To my joy, I found when everything (almost) has changed in my life this fellow is still the same loyal to me, rather in the time of need its usefulness is more felt and it becomes irreplacable.

I would like to think that one of my favourite Wordsworth has written the poem thinking about the books instead of the daffodils. They only truly have given me the "bliss of solitude."