Skip to main content

Posts

Showing posts from January, 2020

Estimating the value of Pi using Monte Carlo Method

The very first moment I was shown this, I was amazed. Estimating something using random events is pretty amazing. The first time I did this in MATLAB, but now, I think I will attempt to do the same in JavaScript. The undelying concept of Monte Carlo Method is to use randomness to determine the value. The method is often used to solve problems that are hard to determine exactly, when there is enough statistical data available. Let us define a square centered at the origin with side of length 2. A circle centered at the origin is inscribed in this square. The assumption that we are using in this method is that if we randomly take a few points within the square, the ratio of the number of points that falls within the circle to the total points taken is equal to that of the area of the square and the circle. That is, Area of square / area of circle = totalRandomSamples / totalPointsInCircle Let us write a JavaScript program that could do perform this with a huge number...

Programming bouncing ball in JavaScript

While studying Newton's laws of motion during my schooldays, I found some of the questions related to bouncing ball quite fascinating. The sheer number of different kinds of questions that one could come up with just a ball bouncing on the ground is quite a lot. My attempt is to create the example as simple as possible. I would not be defining additional classes; I would be using the position value which is already present in the DOM Element  and adding velocity as a parameter to the DOM Element . First, let us define the HTML and CSS to get the visual appearance of the ball and the floor right. <html> <style> #ball{     position: absolute;     left: 50%;     top: 0;     width: 50px;     height: 50px;     border-radius: 50%;     background: #005eff; } #floor{     position: absolute;     bottom: 2px;     background: #000;     width: 100%; ...

Nine year anniversary for BuddyGo

It has been nine years since I bought the domain buddygo.net . Prior to buying a .net  domain, I used to use a .tk  domain as it was free. As I started this project during my childhood, it was hard for me to convince others to pay for this, but eventually, I saved up some money and did it. For a few years, I paid for the domain just for the sake of keeping the ownership. As I have mentioned in one of the previous blog posts, BuddyGo started of as a social network. Later, I started a few blogs in different subdomains which turned out to have pretty high traffic. In the subsequent years, I had to take the project down for many reasons, the main one being my academics. Bringing it back up as a blog, I believe, is a good decision that I made and I think I will keep on writing more posts. Cheers!