Calculating Pi using Monte Carlo Simulation

Monte Carlo Method for approximating the value of pi using ratio of area of circle inscribed in unit length square.

Recently I have been intrigued by the uses of Monte Carlo simulation and a myriad of their uses in probabilistic modelling techniques especially in NLP and social network modelling. I wanted to learn more about the monte carlo process and understand what are some of its basic uses. An often cited example people gave me was that of calculating the value of $\pi$ defining it as 4 times the area of a circle inscribed in a unit length square.

The below figure shows the distribution of randomly generated points falling inside and outside the circle. Also the other figure shows how with the greater number of iterations the value of pi converges to the actual value of pi.

Monte Carlo Method for approximating the value of pi using ratio of area of circle inscribed in unit length square.
Monte Carlo Method for approximating the value of pi using ratio of area of circle inscribed in unit length square.

The intuition behind the simulation process is that if we randomly generate points confined inside a square circumscribing a circle then the probability of the points falling inside the circle will be directly proportional to the area of the circle. Since the circle is inscribed in the square hence its radius is 0.5 and hence the area will be $\pi/4$. This ratio is also approximately equal to the number points randomly generated inside the square which fall inside the circle to the total generated points. The approximation will should converge to the value equal to pi if we have very large number of points ideally tending to infinite points inside the square.

The below code does the simulation and generates the above figures:

The intriguing thing about this simulation is that using just 10000 points I am getting pretty good value of pi around 3.1392. This approximation however will change with each different run of the code as the randomly generated points change.

I am interested in learning more about such basic applications of monte carlo processes so that the understanding of the more complicated models is easier.


A review of research ethics of internet using the Facebook Cornell Collaboration


As a part of my course on Social Visualization (CS 467) I had the opportunity to review the following three articles about ethical research on the internet related to the Facebook Cornell study of emotion on Facebook newsfeed:

Here is my review based on the above articles on the issue of ethics in academic – industry collaboration for social research:

Summary of Articles

The different articles all discuss about ethics of research without consent in the social media platforms specifically in context of the controversial Facebook study on contagion of emotions on Facebook. The three articles shed light on the situation from different perspectives. The guardian article discusses the whole situation in detail and talks about the negligence of IRB by all the parties involved in the study i.e. Facebook, Cornell University, PNAS journal. The WordPress article talks about another social scientist’s experience and pros of doing online research without human consent. The medium article talks from industry’s perspective of why these kind of researches continue to happen at industry level and this collaboration with academia just exposes the need to altering the policies for IRB for online research.

Key ethical points

I think the guardian article highlights how all the involved parties have tried to escape giving explanation of the whole situation and questions if the research was funded by the Army. It exposes the details in the facebook data policy which allows the company to run such experiments however the involvement of academic scientists without proper IRB is questionable. The article also discusses on of those scary situations where the nexus between corporate and academia will be looked as a way to bypass ethical research standards, which is not a good thing.

The wordpress article is by another social scientists who explains using her own previous researches that if the research doesn’t cause any harm then it should be allowed. She offers suggestions on making the research non-harmful by removing the negative sentiment aspect from the study. In her previous research the author entered various chat forums and depending on the experimental design shared their intention of doing research and allowed system to kick them out if the chat room was unwilling to participate.

The medium article talks from the perspective of a previous data scientist and current academic researcher. He advocates the need for a differentiating social media IRB policies with that of the real world scenario. Socio technical systems allow us to run very huge sized experiments with high efficiency which is not possible in the physical world experimental setting. He also details how making online research systems include a consent form and other nitty gritties of IRB requirements makes the systems unusable and reduces the participation because of people’s fear of things that can happen to their data.


According to me, the industry and academia collaboration are really useful and required if we want to do representative researches. Most of the research which happens by the academic community is on very small sample of social media data because of their lack of access. The corporate partnership if done for a more academic cause would help in getting more useful results which can be applied back to the advancement of social systems.

Also, any kind of research which may cause any kind of physical or mental pain should be highly regulated. This however, gives an opportunity to tackle this problem from a more user interface perspective as well. How can we make interfaces which don’t scare people away from participating in research and how can they still serve as mediums of communication of the way the user data will be used.

We cannot control what experiments which corporate companies run without our consent and we rarely get to even get access to their results. Most of the experimental results are used as cash generators for future. However, with the corporate and academic partnership these results can be used for not just the revenue increase of the company but also to advance human science and this in a way demonstrates the involvement of the company in question in corporate social responsibility in some way.


To conclude, I agree to the research nexus between facebook and cornell however I feel the effect of the research should have been limited to positive and neutral messages only so as not to cause any harm. To quote the wordpress article “spreading sunshine” in not unethical.