Wednesday, 11 September 2013

The Monty Hall problem simulated in python.

After spending several agonizing hours on the bed unable to sleep, I decided at 5 in the morning to create a simple simulation for the Monty Hall problem.
The Monty Hall problem is a popular probability puzzle based on the game show 'Let's make a deal' and is named after it's original host, Monty hall.


The Problem in essence is described below.


Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?

The wiki to the problem can be found here.

The code I wrote can be viewed and simulated online here by pressing the run button.

The simulation shows that the participant wins approximately 67% or 2/3 of the time.

A simple description and solution to the problem.






The Code in Python:

## Code starts

import random


win = 0
loss = 0

def game_logic():
    global win,loss
    for i in range(1,10000,1):
        l1 = ["car","goat","goat"]
        random.shuffle(l1)
        t1 = random.randint(0,2)
        player_choice = l1[t1]
        l1.pop(t1)
        t2 = random.randint(0,1)
        door_open = l1[t2]
        if(door_open == "car"):
            if (t2 == 0):
                t2 = 1
                door_open = l1[t2]
            else:
                t2 = 0
                door_open = l1[t2]
        else:
            pass

        l1.pop(t2)
        player_choice = l1[0]
        if (player_choice == "car"):
            win += 1
        else:
            loss += 1

    print "win:" + str(win)
    print "loss:" + str(loss)
    print "percentage wins:" + str(win/100)
   
   
game_logic()
## Code ends

Neat huh ? Python rocks !


Thursday, 7 March 2013

Midnight Maggi Misadventures




December-January is a stressful time for engineering students.Odd sem exams!
Preperation for the exam during this time largely involves studying all night and sleeping all day for most, if not all students.And I was no different.I would start studying at 6 in the evening and go to bed at 6 in the morning.It is not as nerdy as it sounds! For only half of that time did i actually study.

When you have had your last meal at 9:30 in the night,you start to feel hungry by 2-3 am in the morning.I tried to buy some food to eat in the night,but that did not work out in the long run.So, I decided to make maggi during this time.It was perfect! It was simple to make,it did not take a lot of time to make and it required no culinary sense whatsoever!
And so I made maggi,almost everyday till I eventually got bored. ( Who wouldn't ? Its maggi! ) So one day, I decided to make my own masala instead of using the one given in the packet.Not to mention,it was disastrous ! I added some red stuff and some green stuff , both of which were within reach in the kitchen.As the water started boiling,the mixture started to froth.Even with my limited or no cooking experience, I knew that was not a good thing. It subsided however,and the maggi was made.I tried it and by the end of the first mouthful I knew that the red stuff was chilli powder. Chilli powder should not be kept within eyesight in the kitchen !

A few days later, I decided to experiment again. I added butter to maggi and it tasted delicious! It gave a smooth feel to the maggi (almost like actual noodles! ). The innovator in me was motivated to keep experimenting. ( Probably not the greatest ideas i've had! ) From butter, I moved onto cheese . People add cheese to stuff all the time! Cheese is supposed to taste great with everything right ? Wrong! The cheese disintergrated in the water and formed some kind of guey non-solution. It was disgusting and took 40 minutes to cook! Although in its defence ,I probably should have used cheese spread instead of sliced cheese :P

The next time, I decicded to add pepper powder. The pepper powder was stored in a box with a loose cap. ( Of course I din't find that out until much later! ) I tried to force the powder onto maggi,like one does,when one uses a pepper shaker.The cap came off and I emptied a whole bottle of pepper powder onto the pan! The water was boiling at the time and the air was filled with pungent,peppery fumes. So much so that it caused my mom to wake up at 4 am to shout at me!

All in all it was an eventful 2 months rife with excellent experiences!
Looking forward to July :P

Sunday, 11 November 2012

Experiences from the Texas Instruments Analog Design Contest-Phase1a


The Texas Instruments Analog design Contest is divided into III Phases ,Phase -1a, Phase-1b and Phase 2.Phase-1a involved working on the the Texas Instruments Analog Systems Lab Kit or ASLK for short.The kit arrived at our college on September the 20th or so. We did not start working on it right away ( as we probably should have ), We thought at the time, and I quote Calvin (from Calvin and Hobbes ) "We work better under pressure". It turned out later however that "We work only under pressure! "

2-days to D-day.

All teams started working on the kit at the same time ( caused a few clashes ! ). The first part of our problem statement ( problem statement c ) was simple and straightforward and the results from experiments matched the ones obtained from simulation on TINA-TI.The second part, however caused a few problems as it involved embedding an analog multiplier into the given circuits and obtaining plots for different values of control voltage. We had never worked on or even heard of an analog multiplier until then! It took us a while to figure it out from its datasheet and start to work with it.There also wasn't a reliable TINA model of the multiplier available to simulate. As a result, the experiment results we obtained weren't fantastic.

1-day to D-day.
The other teams from our college were already furiously working on their reports and videos ( Yes. A video was required to be made ) while we were yet to obtain the results.The clashes over which team got to use the kit did not help either.

The output of the multiplier with two sine wave inputs
5-hours to D-day.
We tried to change the scale factor pins to 1 ( from its default 10 ) and ended up burning a few pots ( potentiometers ) in the process ( They all caught fire rather brilliantly ) and then out of nowhere, one of them happened to....well not catch on fire and it worked ! the whole setup worked ! and we got all our readings beautifully !

The hard part was hardly over!
The output readings were noted down.It was 10 in the night ( 2 hours to deadline ) and we were all wondering whether to stay over at college. There was still loads of work to be done, graphs had to be plotted, results were to be tabulated and the video was still to be made. All within one hour. Me and Jithin started getting bits together for the report while Akshsay and Karthik plotted the graphs.

11:30 came and went and so did 12:00. I think a modified version of Murphy's law can aptly be quoted here. "When meeting a deadline, everything that can go wrong , WILL go wrong ! I was working on some of the image files when out of the BLUE, my HP laptop, running on an I7 processor displayed the infamous Blue Screen Of Death ( Commonly known to fellow windows users as BSOD ) for the first time! The timing could not have been more perfect!

12:50
We worked together and finally managed to upload the report from Jithin's laptop albeit 50 minutes late.In a word, the whole experience could be described as "Chaotic"

After this ordeal, we played 'worms' on Akshay's phone, Karthik played Call of duty and we watched a few big bang theory episodes.We also got to walk around UVCE at 3 am. Yeah, that part was pretty awesome !

Saturday, 22 September 2012

That good feeling !


We are all burdened with responsibilities,with deadlines,we face roadblocks on a day to day basis.But what are those things that make life worth living ? What are are those things that make you happy for the tiniest most fleeting moments ? What are those things that you see beauty in? What are those things that make your heart lighter? (I do not know how many of you guys have experienced this, but I actually feel my chest expanding and a warm glow spreading around my chest! Of,course it could just be gas,but i am not entirely sure.)

I realised 3 things that do that to me.

One of them is watching Football. Its an amazing feeling when you are awake at the middle of the night and watching barcelona play Real Madrid or Germany play spain.Its amazing how the ball is worked from a useless position to a goal scoring opportunity.Its amazing how Iniesta and Messi create magic and conjure a goal out of nothing.Its amazing !!

The other is Electronics.When you hold in your hand an Iphone, you cant help but smile.Its absolutely beautiful how you can peep into that little window and be able to talk to your friend on the other end of the world.Its beautiful how you can walk the streets of Newyork without moving an inch. Its beautiful how the little pieces of logic fit together so compactly to form a whole ! Its beautiful how those little transistors turn on and off at just the right moments so that you can fling your very angry red bird at a bunch of pigs!

The third is probably the simplest of all.It is that feeling you get when you ride your vehicle back from college on newly ashphalted roads and hit all green lights !That soaring feeling !

Thursday, 29 September 2011

Treading The Trail

Mullayangiri-BabaBudangiri-Kemmanagundi Trek.

WHAT-Mullayanagiri is the highest mountain in Karnataka standing at 1936m from sea level.BabaBudangiri is famous for its Coffee estates.
WHERE-Chikmaglur district in Karnataka.
WHEN-Departure:11:00pm on Saturday.....Arrival 5:00am Tuesday.

After many postponements,we decided to go on this trek on Saturday the 24th of september.We had decided to go by train upto Kadur and then catch a bus from there to Chikamaglur.There was a slight confusion in the time of departure of the train,and it was our good luck that we all managed to board it even though we were an hour late.There were 6 of us, all from UVCE.Sumukha,Suhas and Samarth had never trekked before, while me,Akshay and Karthik had a little experience.The train departed Bangalore at exactly 11:10pm.

We played cards on the train and none of us slept as we had to get down at Kadur at around 3 in the morning.We got out of the station and spotted a bus headed for chikmaglur just outside.The bus ride was pretty eventful and we saw the remains of an accident.A KSRTC bus had toppled over completely just around a blind bend.The people in our bus estimated that the accident might have happened just 10 or 15 mins prior to our arrival there.We reached Chikmaglur at 4am.

To reach Sarpadhari(The base of Mullayanagiri) one must catch a bus headed to Attigundi.But there are very few or perhaps even no KSRTC buses that take that route.So we had to wait for a private bus,the next private bus headed that way was however, at 8am.We had our breakfast at the hotel in the bus stand and hired a van driver to drive us to Sarpadhari.We reached Sarpadhari at around 7:15am and began our trek at 7:30 am.There was no breeze and a hot sun bared down on us.The trail was easy to follow and it snakes its way up the mountain.At some points it becomes difficult to decide which path to follow,but happily we always ended up taking the right one.One can say that this is an easy climb if one starts a bit early and avoids the hot sun.Following the trail, we reached a place where there is a sculputre of  Nandi.we rested here for some time and had some light snacks.We came close to the top at 9:30am. There are some beautiful caves at the top that we explored.The water inside the cave was ice cold.Anyone trekking to Mullayanagiri must not miss this place!!

At the top we relaxed our legs a little and I met an old schoolmate of mine(of all the places in the world).We began our descent from Mullayanagiri at around 10:45am and began the journey towards Bababudangiri.We were told that we would have to trek in the direction of a BSNL tower.At some point later,we lost our way.We could see the road,but could not find the trail.We lost about 20 minutes here.We found out later that we had ended up on the wrong side of the mountain that we were traversing.We reached a stone with an image of Swami Vivekananda at around 12:45pm .There was a checkpost on the road right below us.We had our lunch here(Each of us had carried 12 chapatis).

We resumed our trek towards the tower 45 minutes later.This was the most exciting part of the trek!!We had to walk right on the edge of the mountain with a huge gorge to our right.One slip of the foot and we would tumble down and never be heard of again.Thankfully, that did not happen,and we proceeded slowly on.The trail here,though pronounced was blocked by huge rocks and it was a bit difficult to maneuver here.We finished this part of the journey in 15 minutes and arrived at some plain land.

From hereon,the journey became a little more difficult as the sun had climbed higher up in the sky and was on our heads.We stopped for rest and drinks more often and finally reached close to the base of the tower at 3:30pm.The trail leads to a dusty road which leads to a small waterfall called Manikyadhara.There are some small ponds along the road from Manikyadhara to BabaBudangiri.We spent some time here and reached BabaBudangiri by 5:25pm.


We rented a shed at BabaBudangiri and stayed there for the night.One can see what seems to be all the stars there are,if one looks up at the sky at night here.The view of the adjoining valley was spectacular!! We decided not to trek to kemmanagundi as some of us were pretty exhausted from the previous day.We hired a jeep that dropped us off at the hebbe falls - kemmanagundi intersection.The driver told us to take a left at a point further along the intersection to reach a road that would take us to hebbe falls.We took his advice and could,however find no road. we wasted some good time there.Later a policeman told us that we had to take a right and not a left!!

Running late we started trekking to Hebbe falls.The path seemed to go on and on.We were told that the last bus leaving kemmanagundi was at 4:30pm so we decided not to go all the way and turned back.We reached  Kemmanagundi at around 3:30pm.On the we saw a fresh water crab(The highlight of that journey : P ) We had lunch at small canteen atop Kemmanagundi and left for Birur by bus at around 4:00pm.We caught a train from Birur to bangalore at 11:45pm.

Some Contact numbers :
Swami (Van driver from Chikmaglur to Sarpadhari) : 9980251196 ( Cost: rs270 first asked for rs350)
Suresh (Owns a store atop BabaBudangiri,rents sheds) :9481583277 (Cost 100,150,200 / shed )
Irfan (jeep driver from BabaBudangiri to Kemmanagundi) :9480232935 ( cost 1200 for ride,first asked for 1500)


Thursday, 8 September 2011

Why UVCE is one of the best engineering colleges in Bangalore.


UVCE is among the best colleges in the country and among the oldest too. There are many many reasons to join
UVCE, and I in this article will try to outline a few.
One of the very first things that stand out is the amazing amount of free
time one gets at UVCE, in other colleges however, the students are regularly
bombarded with exams and tests and surprise quizzes. The students at UVCE
can utilize this extra time in developing soft skills and pursuing other interests.
Some of the students at UVCE are involved in research activities in as early as
2nd year which is a result of them not being bogged down by hectic classes all
the time.
Once a student enters UVCE the student automatically learns to learn
on his own. Learning on one's own is always a good thing. Unlike some other
colleges, UVCE does not spoon feed the syllabus to its students. Also the syllabus
of Bangalore University cannot be found in just one book and hence the students end up referring to more than one
author while studying the subject, which is very good in the long run.
One of the common complaints I hear from my friends from other institutions
is how little they communicate with their seniors. I can safely say that in
UVCE the seniors are everything. They are the guides, the mentors and sometimes
even teachers. They advice on everything from which book to buy for a
certain subject through which classes I can safely bunk to which graphics card I
need to buy for my computer. Ultimately this relationship leads to the creation of
a wide network of people in my field who I can approach at anytime for anything.
UVCE has a massive alumni base spread out around the country and the
world, some of whom occupy important positions in big organisations. Some
alumni visit the campus to interact with the current batch of students and offer them an insight into the industry and much
more. Some of the younger and more recent pass-outs also involve themselves in the activities and fests that happen in the
campus.
UVCE organises four fests in its campus. These fests comprise of various technical and cultural activities designed
to test the varied skills the students posses.
One of the best events that I participated in during my first semester was the mock placement event. The event
was a simulation of the actual process of campus recruitment that the companies undertake. Even though I did not win, I
found out exactly why I did not and what areas I needed to work on to be more recruitable .The event was a fantastic learning
experience. I also had the opportunity to talk with some of the best
placement trainers there are. One takes a lot back from such activities.
Also, during the many fests, I volunteered for some of the events. I
have realized that Volunteering is a fun job, where not only i learned about
the many things that go into the making of a fest but also I learned to make
sure the event proceeds smoothly without hindrances. This taught me to be
a more efficient team player and to individually manage a given responsibility.
These are some very important traits that one must develop and I am
glad my college played a part in me learning a few.
Contrary to the opinion of some ill informed people the lecturers at
UVCE are some of the best. Most of the lecturers at UVCE hold doctorates
and are highly reputed in their respective field. As a result UVCE is one of
the best engineering colleges in India and is highly regarded in universities
abroad.

Also unlike other colleges which admit students on the basis of management and COMED-K,UVCE only admits
students through CET, those being some of the highest rank holders in the state. Hence, all the students at UVCE are meritorious.
This creates a great learning atmosphere.
For most people the engineering course is a gateway to the world of high
paying jobs and UVCE does a fantastic job of delivering it to them. Through the
efforts of the placement and training center the final year students at UVCE walk
away with multiple job offers. Some students at the time of graduation have 4 and
even 5 offers to choose from. The placement office at UVCE prides itself in providing
the students with "the" job and not just "a" job. To quote some statistics, In
the year 2010-2011, 923 job offers were received by a total of 400 to 450 students
in the college with Cognizant being the highest recruiter. One of the unique things
about the placement office at UVCE is that two students in their final year from
each department get to be placement coordinators for one year during their final 2
semesters. The Placement office at UVCE is one of the few where students get to interact with the industry HR and invite
them to the campus for placements. The placement records at UVCE are among the best in the state.
Finally, I would like to say that studying at UVCE has been fun for the one year that I have been in it. The bottom
line is that UVCE is the best option for students who do well in their CET.

Sunday, 28 August 2011









It all started when we(the class of ECE UVCE) were waiting for the Signals class on friday the 26th August 2011.Someone just said " Whos up for trekking at Savandurga?".The word spread and by the end of the class,10 guys confirmed that they would be coming.Texts were exchanged and we all decided to meet up at Majestic bus stand at 7 in the morning.Satish was a little late in arriving :P but otherwise all else went smoothly.

When we asked the TC at the KSRTC bus stand about where to board a bus to Magadi,the collecter said that we would have to catch a bus from the Kalasipalya bus stand at the city market.(A little heads up here,there is a direct bus from kalasipalya to Savandurga at 6:30 am.)We reached market by 7:45 am and by 8:00 am sharp our bus was on its way to Magadi and onwards.I felt that since we had gotten on a private bus,it meandered around Bangalore a little more than KSRTC buses do.The ride cost us rs 25 per head.The bus dropped us off at the place where one has to take a diversion from the main road to reach Savandurga.The autorikshaw drivers standing there tried to convince us that there would not be a bus towards our destination for a long time and we would be better off taking the autos.But we had not waited 5 minutes when a bus did arrive.we reached the base of Savandurga and waited while a friend of ours arrived from Tumkur.There are no good hotels here and its better to have breakfast in Bangalore itself.

We began our trek around 11:00 am(which is pretty late) thankfully there was no sun about.A little overgrown path leads to the base of the cliff.(It was here that a dog started following us,or perhaps leading us,we dont know which :P )One look at the cliff and we all knew that this would not be a walk in the park.The foreside of the hill was very steep and completely bald.Absolutely no footholds.The young hotblooded guys that we were,we decided to climb the hill on this side.Although it was pretty clear that the path was around it.We were going good till a point where it was really difficult to climb anymore,because it was very steep.We continued on at a very slow pace.

This is one of the times that we are reminded that man cannot cross every obstacle that nature throws in his path(Although an experienced rock climber could have done it,we certainly could not)One of my friends Akshay had climbed a little higher than the rest of us and he realised that it was impossibe to go on that way.Within moments,we saw him slipping,he was on all fours and trying desperately to hold on to something,as the rest of us watched.The thing that gave us all a horrifying moment(and a " come to your senses call") was what happened next.The water bottle in Akshay's backpack slipped out of its pocket and and went tumbling down the slope.It acquired a high momentum and finally crashed into one of the rocks.It  was a terrifying moment watching the bottle go down at such a pace.We all began to think about our fates if one of us slipped on that slope.

After that incident,we hastily followed the right path(The path is marked with yellow arrows).From hereon it was a simple enough trek to the top.we stopped a couple of times for pictures and rest and also met a few fellow trekkers from Bangalore.On the way to the top we saw a few forts,perhaps built during the Kempegowda era.We slowly made our way to the top,the dog following us all the while :P .

We reached the summit at about 1:00 pm,and I believe that if one does not stop for pictures and to savour the view,one can get there in an hour and a half max.The view from the top was absolutely stunning!!we rested and ate some snacks.Slowly,the wind picked up!!and in a few minutes had reached a really high speed.The wind in my face felt delightful.We were again awed by the superb power of nature.There were times when I(being quite light)was thrown off by the wind.We spent some quality time at the top.(And we did not litter the place.Please do not do it)As we sat gazing towards the east,(The direction of Bangalore)We could see the rain clouds heading our way.Hurriedly deciding that it was best to leave as soon as possible,we left the place.

We had not gone some distance,when the rain hit us.As a result we were forced to slow down our pace.Tiny streams began to run down the side of the hill and we had to tread very carefully.but the rain did not last and soon it was reduced to a drizzle.I made it down without incident and reached the base at around 2:30 pm.It had taken me a little more than a half hour.The rest arrived within 10-15 minutes of my arrival.I was later to know that some of the guys had slipped and fallen a couple of times.At the base we rested at a temple like place(I could not be sure as I could hear A.R. Rahman's "Jai Ho" blaring inside.


From the base,we walked some distance to the gate of Savandurga.Here we waited for a bus headed for Bangalore.I got down at Kengeri.And reached home around 7:30 pm.