The Hypergeometric Distribution

We have seen that the binomial distribution is based on the hypothesis of an infinite population N, a condition that can be practically realized by sampling from a finite population with replacement.

If this does not occur, meaning if we are sampling from a population without replacement, we must use the hypergeometric distribution. (In reality, if N is large, the hypergeometric probability density function tends towards the binomial).

The hypergeometric distribution is used to calculate the probability of obtaining a certain number of successes in a series of binary trials (yes or no), which are dependent and have a variable probability of success.

The hypergeometric distribution allows us to answer questions like:

If I take a sample of size N, in which M elements meet certain requirements, what is the probability of drawing x elements that meet those requirements?

Continue reading “The Hypergeometric Distribution”

The Negative Binomial Distribution (or Pascal Distribution)

The negative binomial distribution describes the number of trials needed to achieve a certain number of successes in a series of independent trials. For example, it answers the question: flipping a balanced coin (50% chance of heads on each flip), what is the probability that the third head comes up exactly on the fifth flip?

The negative binomial distribution is useful in many fields, including statistics, economics, biology, and physics. And also in “our” SEO.

(If instead we want the probability of a certain number of successes in a fixed number of trials, say three heads in five flips, the right tool is the binomial distribution: the negative binomial turns the question around.)

Continue reading “The Negative Binomial Distribution (or Pascal Distribution)”

Probability: Sample Space, Events, Permutations and Combinations

How likely is it that a page reaches the first results page? Or that an A/B test gives a reliable answer? Questions like these — seemingly very different — share the same root: to answer them we need probability and combinatorics. In this post we lay the foundations, starting from the sample space and exploring together the basic tools that will accompany us throughout the whole path.

Continue reading “Probability: Sample Space, Events, Permutations and Combinations”

Logistic Regression: What It Is, How to Read Odds Ratios, and an Example in R

Sooner or later, every traffic analysis arrives at the question that really matters: did this visit turn into a customer, yes or no? We don’t care how much a session converted, we care whether it did. And right behind it comes the next question: which sessions are more likely to convert? The ones arriving from a search for the brand name? The ones browsing more pages? The ones on desktop?

With linear regression we learned to predict a number. Here, though, the outcome is a switch, on or off, and a straight line is not the right tool: we’ll see it even ends up predicting negative probabilities. The right tool is logistic regression, one of the most widely used models of all, from marketing to medicine. Let’s build it together, starting from an example with conversions.

Continue reading “Logistic Regression: What It Is, How to Read Odds Ratios, and an Example in R”

Non-Parametric Tests: The Wilcoxon Test for Non-Normal Data (with R Examples)

Imagine comparing session durations between two groups of pages: those with a featured snippet and those without. You run a Student’s t-test and get a p-value of 0.08. Not significant, apparently. But looking at the data, you notice the distributions are heavily skewed: a few pages with very long sessions, many with very short ones. The t-test assumes normality, and here we are light-years away.

The Wilcoxon test is a non-parametric test that makes no assumptions about the shape of the distribution. It works on ranks, not on original values: it orders all data from smallest to largest and assigns scores based on position. This makes it especially useful in SEO, where many metrics (sessions, CTR, rankings) are anything but normal.

Continue reading “Non-Parametric Tests: The Wilcoxon Test for Non-Normal Data (with R Examples)”