Skip to main content

Posts

Showing posts with the label Statistics

What is SUTVA for A/B testing?

Imagine if person B’s blood pressure reading depends on whether person A receives the blood pressure medicine in a randomized controlled trial. This will be violating Stable Unit Treatment Value Assumption (SUTVA) SUTVA states that the treatment received by an individual should not influence the outcome we see for another individual during the experiment. I know the initial example sounded absurd, so let me try again. Consider LinkedIn A/B testing a new ‘dislike’ reaction for its users, and the gods of fate chose you to be part of the initial treatment group that received this update. Excited after seeing this new update, you use this dislike reaction on my post and send a screenshot to a few of your connections to do the same, who are coincidentally in the control group that did not receive the update. Your connections log in and engage with my posts to use this dislike reaction, but later get disappointed as this new update is not yet available to them. The offices of LinkedIn are tr...

The Gambler's fallacy

In a world riddled with conflicts and disagreements, we all can wholeheartedly agree that the probability of my articles becoming viral and the Bitcoin price seeing a 1000% increase is not only independent but also extremely unlikely. If I claim that these two events are dependent in an attempt to gain engagement from the large crypto community, does it not make me a conman? Or I could simply be a common man (or a conspiracy theorist) who mistakenly perceives independent events as somehow interconnected. Another group that commonly struggles with this issue is individuals with gambling addictions. Don’t we all have those friends (or in a few cases, we were those friends) who experienced consecutive losses in gambling but persisted because they believed their turn to win was imminent? It could be portrayed as a tale of remarkable persistence and unwavering determination when that friend miraculously wins a significant sum of money, potentially bankrupting the casino. However, there is o...

Can you defeat Monty Hall to win a Batmobile?

  You slipped after accidentally stepping on a banana peel and somehow fell into another dimension where people are in game shows all the time. As you dust yourselves off and stand up, you realize you are in the 1960s version of the game show “Let’s Make a Deal.” The host of this show, the late Monty Hall, looks at you suspiciously at first but later presents three doors in front of you and asks you to choose one. You don’t trust strangers, so you demand to know what’s happening before you make your next move. Monty Hall patiently explains that there’s a brand new Batmobile behind one of the doors (yes, Batman is real in this dimension), and goats behind the other doors. You could own the Batmobile if you correctly guess the door behind which it was hidden. You pull your Batsuit out of your pocket to don the mask of the world’s greatest detective (as per DC Comics) and analyze the three doors with a careful gaze. You look meticulously for any minuscule details that might give away ...

A Poisson pondering

It might seem counterintuitive, like, how could a sample size be infinite? But let us remember the classic application of the Poisson distribution — modeling the probability of a given number of events occurring in a fixed time interval. To better understand it with an example, consider the probability of a given number of buses arriving at a station in an hour. Now, to look at it from a binomial distribution perspective, we could divide this one hour into sixty Bernoulli trials. Each trial models the probability that a single bus will arrive in that particular minute. The problem with this approach is that it simply restricts the number of buses that could arrive at any given minute to one. In the real world, it is not a completely unimaginable scenario that multiple buses could arrive back-to-back within a minute. We could increase the granularity by opting for 3600 Bernoulli trials instead of 60. It would mean we moved away from looking at minute intervals to seconds, and our proble...

The common sense and the null hypothesis!

  “You don’t accept the null hypothesis. You could only fail to reject it!” The essence of hypothesis testing lies in this statement. When you get a p-value that exceeds the level of significance, it means your sample hasn’t provided enough evidence for you to reject the null hypothesis. But it doesn’t necessarily mean there is enough evidence to accept that null hypothesis. I know! Our common sense tells us that failing to reject something means accepting it, but common sense doesn’t always work in the world of statistics. (Else, why would people roam with dice in their pockets!) Sometimes when we fail to get significant results, it might be because our sample is imperfect. Our sample might not be a truly random one, or our sample might be too small to meet the assumptions of the central limit theorem. No wonder we get p-values exceeding the significance levels in such cases, preventing us from rejecting the null hypothesis. Our next logical step would be seeing how this data was ...

Kryptonite of the correlations

  It is easy to get lost in the world of correlations! But make no mistake, you have valuable information about your data by looking at the correlations between the variables. And if you’re planning to build a linear model using supervised machine learning, the presence of correlated variables will exacerbate the model’s accuracy. Hence, looking at the correlations between continuous variables is almost a non-negotiable task, and one of the ways to do it is by calculating the Pearson correlation coefficient for these variables. Pearson coefficient is the default mode for many, including me, for testing correlations. But Pearson coefficient has found its kryptonite in the form of the non-linear relationship between the variables. Pearson coefficient makes sense only when there is a linear relationship between the variables and is not very useful when the variables have a non-linear relationship. But it is high time we adopt other measures of correlation in addition to the Pearson co...

The denominator of sample variance!

  When I was young, I tried to fit every new thing I learned with what I already knew. But every time I learned something that didn’t fit my view of the world, I rejected it altogether! I could not sustain this approach for long because it resulted in poor grades. I soon had to start mugging up stuff without seeking proof for them. One such thing I accepted without thinking much was using “n-1” in the denominator while calculating variance. As you already know, “n” represents the total number of observations here. But today, for the first time in my life, I came across two different versions of the variance — population variance and sample variance. Population variance is calculated with an “n” in the denominator, whereas sample variance requires an “n-1”. I was curious about this difference and went on a fact-finding mission online. And what I found just blew me away and made me admire the elegance of statistics! Before understanding what it is, let us take a look at the process o...

My views were skewed regarding skewed distributions!

  I have been doing it wrong my whole life. I realized it only very recently. I used to look at the hump to determine the direction of skew for a distribution. But hump represents the most frequent value in the distribution. It is not skewing the distribution. If anything, that hump is trying its best to preserve the normal distribution despite the skewness. The actual culprit here is the long tail. It consists of the outlier values that are skewing the distribution. From now onwards, I will keep in mind to look at the tail instead of the hump to tell whether a distribution is left-skewed or right-skewed.

Unravelling the secret behind numpy.std!

  I know you could recite the formula for sample standard deviation even in your sleep. That (n-1) in the denominator inside the square root must be no stranger to you. There’s a good chance you already know that a sample has n-1 degrees of freedom, which is why we use it in the denominator instead of a straightforward “n.” It is a no-brainer that using the .std() function to calculate the standard deviation for a NumPy array is a piece of cake for you. But if you haven’t heard about the “ddof” parameter in this function yet, let me caution you against using the .std() directly to calculate sample standard deviations. This parameter accounts for the degree of freedom while calculating standard deviation, and its default value is zero. If you aren’t setting it to “1”, you are calculating population standard deviation instead of the sample statistic. Hence, always cross-check that you are setting the appropriate value to the ddof parameter while using the .std function.