Friday, July 20, 2018

Solving the Monty Hall problem using Bayesian inference

The month hall problem is one of my favourites. I came accross How to solve the Monty Hall problem using Bayesian inference, which used my other favourite topic, Bayesian inference. My only criticisim of the post is that P(E) is a little confusing. The following formulation with separate P(B*) and P(C*) notation suits me better:

P(B*) = Probability that Monty will open door B (given that the user has choosen door A) = 1/2

P(C*) = Probability that Monty will open door C (given that the user has choosen door A) = 1/2

P(C*/B) = Probability that Monty will open door C (given that the user has choosen door A and car is behind door B) = 1/1

P(C*/A) = Probability that Monty will open door C (given that the user has choosen door A and car is behind door A) = 1/2

P(B*/C) = Probability that Monty will open door B (given that the user has choosen door A and car is behind door C) = 1/1

P(A/B*) = Probability that the car is behind door A, given that Monty has opened door B = P(B*/A) * P(A) / P(B*) = 1/2 * 1/3 * 1/2 = 1/3

P(C/B*) = Probability that the car is behind door C, given that Monty has opened door B = P(B*/C) * P(C) / P(B*) = 1/1 * 1/3 * 1/2 = 2/3

P(A/C*) = Probability that the car is behind door A, given that Monty has opened door C = P(C*/A) * P(A) / P(C*) = 1/2 * 1/3 * 1/2 = 1/3

P(B/C*) = Probability that the car is behind door B, given that Monty has opened door C = P(C*/B) * P(B) / P(C*) = 1/1 * 1/3 * 1/2 = 2/3

As you can see, it is two times better to switch doors, i.e. if Monty has opened door B, switch to door C. If Monty has opened door C, switch to door B.

Wednesday, July 18, 2018

Behaviour before intellect

A friend of mine who has a young child asked me whether I had any curriculum in mind for teaching a child. I told him that for my 6 year old, my focus was on making sure that he was behaving properly, i.e. basic discipline, not on any intellectual subjects like mathematics. Behaviour is the foundation on which everything else is built.

Thursday, July 05, 2018

Difference between hub and switch

You can listen to traffic/packets by connecting to a hub but not a switch.

The Difference Between a Router, Switch and Hub: "In a hub, a frame is passed along or "broadcast" to every one of its ports. It doesn't matter that the frame is only destined for one port... A switch, however, keeps a record of the MAC addresses of all the devices connected to it. With this information, a switch can identify which system is sitting on which port. So when a frame is received, it knows exactly which port to send it to..."

How do i capture all traffic on a switch: "A switch will never forward 'other' traffic (traffic that is not directed to your ethernet mac address + broadcast) to your port unless you tell it to do so. So, if you did not configure a mirror port on the switch, you will only see ... your own traffic & traffic to multicast and/or broadcast addresses"

Friday, June 29, 2018

JTable background paint problem

I have a Java JTable with JFormattedTextField in it. I want to set the background color of text field to red when the value in it is not valid. Naturally, I added a focus listener to the text field and set the background color in focus lost event. During tests, I noticed that the background changes when I click on another text field in table but does not change when I press the tab key. The solution is to call JTable.repaint() after setting the background. I think the reason it works when I click on another text field is that during that click, JTable.repaint() is automatically called. Another adventure/nightmare in Java UI...

Wednesday, June 27, 2018

Social Media Diet

As someone whose job requires strategy development, team management, design and software development, concentration is my main asset. When left unchecked, social media consumes a lot of concentration. My social media habits are as follows:
  • I do not watch TV. I rarely watch any movies since I have already watched the best ones.
  • My main sources of information are my YouTube subscriptions. I spend at least 1 hour a day watching videos of those channels. They are related to technology, lifestyle and business, with the occasional cat video sprinkled in between.
  • I listen to podcasts or ebooks while commuting.
  • All notifications on my mobile are turned off.
  • On my mobile, do not disturb is automatically turned on after 22:00.
  • Most Whatsapp groups are in silent mode.
  • I don't have Facebook, Instagram, Twitter on my mobile.
  • I have Facebook on my laptop. Most of my contacts on Facebook are in unfollow mode. This cleans up my Facebook page and let's me spend less than 5 minutes a day on Facebook. I use Facebook mainly as a photo album of friends, not as a source of information.
  • I don't look at my mobile while eating or in WC.
These habits free up a lot of time compared to the majority of people who seem to be addicted to their mobile. I spend that time on deep thought which provides me with lots of ideas that I note in Gmail, Calendar or Drive.

Tuesday, June 26, 2018

Effective Jira

I am using Jira to record and track issues. After I have recorded an issue, my daily workflow is as follows: In the morning, I enter a comment about what I plan to do that day regrading theissue and how I plan to do it, including any questions I have. During the day, I update the comment with what I did and how I answered my own questions, or sometimes, how I got stuck and had to change course. In a way, I do micro-planning, micro-design and micro-implementation, all in a diary style.

The next time I work on the issue, I repeat the same workflow. This allows me to clarify the problem and help me quickly get up to speed when there is a long delay (e.g. 1 week) before I can touch the issue again. It also helps me prepare for our daily Scrum meetings. If it is a long running issue, I can quickly see what I did along the way and be able to easily explain why it took so long, especially if it is an issue that needs input from other people and those inputs were delayed.

Sunday, June 17, 2018

New web application

I developed a new web application and deployed it on my VPS. It has a HTML + Javascript frontend and a Nodejs backend. The app daily checks if a certain Turkish law (4734 Kamu İhale Kanunu) has been changed and informs the people on the email list.

I used Nodemailer and Mailgun to send emails. I first tried Gmail but it blocked messages to other emails, so I switched to Mailgun.