Get startedGet started for free

eCommerce Ad Simulation

1. eCommerce Ad Simulation

Welcome to the final section of Chapter 2. Here you will be bringing together everything you have learned so far to build a sophisticated ecommerce ad simulation. By the end of this section, you will learn how to model a complex DGP by breaking it down into simpler parts. You will then use the statistical model to estimate probabilities.

2. eCommerce Funnel

Consider a typical ecommerce web funnel. Ads are shown on different websites. Some potential customers click on the ads and may signup. After signing up, they might end up purchasing something on the website. Given this DGP, let's build the underlying statistical model. We'll first focus on the flow till signup and later work on the purchase flow.

3. Signup Flow

For the signup flow, the number of ad impressions you get is a count variable. This is typically modeled using a Poisson random variable. We can assume that the rate parameter of the Poisson random variable follows a normal distribution, but again you can choose any reasonable continuous distribution. After an ad impression, a customer has a binary decision - to click or not to click. Binary decisions are best modeled using the binomial random variables. But a binomial random variable requires a rate of success. We can pass in a historical clickthrough rate or go a step further and have a distribution on the clickthrough rates. Similarly, after clicking an ad, signup is a binary decision, which can be modeled using a binomial RV. Here the rate of success is the signup rate. As you can see, you can be remarkably flexible in how you define the data generating process. Next, let's look at the purchase flow.

4. Purchase Flow

As a final step, let's construct the purchase flow. For each signup, the decision to purchase or not is again binary and can be modeled by a binomial random variable governed by a purchase rate. Now if a purchase occurs, we want to know the value of that purchase. Purchase value is typically a positive real number and can be modeled by any continuous random variable. Here I choose the exponential random variable governed by a historical average purchase value. In the next few exercises, you will build this entire flow using numpy. You will then simulate outcomes and calculate probabilities. The exercises in this section might seem daunting and stretch you a bit, but these concepts form the foundations of any data generating process and simulation, so they are worth learning. I've personally utilized such flows countless times in my own work.

5. Let's practice!

Now let's code up this ecommerce example in the exercises.

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.