## Preparation

In textbooks, calculations are mainly performed by Excel functions. Although Excel has an excellent GUI, it does not have enough API libraries to connect to external web systems or data analysis tools. Therefore, we will use Python to perform the same calculations as in the textbook. Here are the preparations for this.

### github

• The jupyter notebook file on github is here .

• If you want to run it on google colaboratory here

### Author’s environment

This is the author’s environment.

The author's environment.

ProductName: Mac OS X
ProductVersion: 10.14.6
BuildVersion: 18G95

Python -V

Python 3.5.5 :: Anaconda, Inc.


import numpy as np
import scipy
from scipy.stats import binom

%matplotlib inline
%config InlineBackend.figure_format = 'svg'

import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns

print("numpy version :", np.__version__)
print("matplotlib version :", matplotlib.__version__)
print("sns version :",sns.__version__)

numpy version : 1.18.1
matplotlib version : 2.2.2
sns version : 0.8.1


## Overview

We live in a limited time, and all we can know is the mean and its variance (standard deviation). For example, in the marketing world, the number of visitors per day, the number of products sold per day, etc. So what can we learn from that limited information? If the number of visitors today is 1,000, what is the probability that the number of visitors tomorrow will be 500? And what is the probability that the number of visitors will be 1500? The answer to these questions can be found in the probability distribution.

In “Strategic Theory of Probability Thinking,” the numbers corresponding to the mean and standard deviation that determine the shape of the probability distribution can be expressed by two parameters, $M$ and $K$. $M$ is the consumer preference itself, and $K$ is a function of $M$. The book consistently asserts the following

Preference controls a brand’s market share, penetration rate, and number of purchases. There are three reasons for this (copied from a textbook): 1.

1. preferences are in the minds of consumers and govern their buying behavior. The direct evidence is that the BP-10 Share Model, based on consumer preferences, can predict the actual share with relatively high accuracy. Consumer preferences dominate market share and dominate sales. In other words, given 100% awareness, 100% distribution, and enough time, preference and unit share are the same thing. The preference is in the mind of the consumer, and the unit share is the actual manifestation of that preference. 2. With the negative binomial distribution model, the penetration rate and frequency distribution of categories and brands can be predicted very accurately and close to reality with only two parameters, M and K. Both $M$ and $K$ are functions of preferences. 3. Using the categories M and K, unit share, and Derisleigh S as inputs, the Derisleigh NBD model can accurately predict very realistic penetration and frequency distributions for each brand. It can also accurately predict the switching between brands. Both Delisleigh $S$ and $K$ are functions of preferences.

In this site, we follow the “Strategic Theory of Probability Thinking”.

1. binomial distribution
2. poisson distribution
3. negative binomial distribution
4. summary of Poisson distribution and negative binomial distribution
5. key equations governing sales
6. Delishley NBD Model

The explanation will follow the order of.

## 1-1. Binomial Distribution (Binomicl Distribution)

### 1. Binomial Distribution Formula

Binomial distribution is a probability distribution in which $\displaystyle N$ trials with success probability $\displaystyle p$ are conducted and the number of successes $r$ is used as a random variable. In general, it is defined as a probability mass function as shown below. The reason why it is a probability mass function instead of a probability density function used to explain normal distribution is that $r$ is a discrete value that can only take positive integers.

$$\frac{N!}{r! (N-r)!} \times p^r \times \left(1-p\right)^{N-r}\cdot \cdot \left(1\right)$$

In this chapter, the binomial distribution is explained using a lottery as an example. Suppose there are a total of $n$ lotteries, and $\theta$ of them are winners. Then the probability of getting a winning lottery ticket on the first draw is $\displaystyle \frac{\theta}{n}$. The probability of getting a bad lottery ticket is $\displaystyle 1-\frac{\theta}{n}$. Since the number of times you win the lottery is $r$ and the number of times you lose the lottery is $\displaystyle N-r$, for example, the probability of winning the lottery the first $r$ times in a row and then losing the lottery $1-r$ times in a row is

$$\left(\frac{\theta}{n}\right)^r \times \left(\frac{n-\theta}{n}\right)^{N-r} \cdot \cdot \cdot \cdot \left(2\right)$$

This becomes Now we need to think about the combination. As we learned in high school math, the combination is the probability of hitting a prize $r$ times out of $N$, so $\displaystyle {}_n \mathrm{C}_r = \frac{N!}{r! (N-r)!}$ and

$$\frac{N!}{r! (N-r)!} \times \left(\frac{\theta}{n}\right)^r \times \left(\frac{n-\theta}{n}\right)^{N-r}\cdot \cdot \cdot \cdot \left(3\right)$$ The result is.

### 2. Example of python calculation

x = np.arange(100)

n = 100
p = 0.3
mean, var, skew, kurt = binom.stats(n, p, moments='mvsk')
print("Mean : ", mean)
print("Standard deviation :", var)

plt.xlabel('$r$')
plt.xlabel('$r$')
plt.ylabel('$B(n,p)$')
plt.title('binomial distribution n={}, p={}'.format(n,p))
plt.grid(True)

y = binom.pmf(x,n,p)
plt.scatter(x,y)
# sns.plot(x=x, y=y)
# sns.scatterplot(data=tips, x='total_bill', y='tip')

plt.show()

Mean : 30.0
Standard deviation : 21.0


## 1-2. Poisson Distribution

### Meaning of Poisson distribution

The Poisson distribution is a distribution that follows the number of random events that occur $\mu$ times per unit period. The Poisson distribution has only one parameter, this $\mu$. The formula is

$$P\left(r|\mu\right) = \frac{\mu^r}{r!}e^{-\mu}$$.

This is a good example. The following are the results of calculations for each of the cases $r=0,1,2,3,4$ for $\mu = 0.6$, following the instructions in this book.

.
.234.
$r$01234
Probability54.88%32.92%9.88%1.98%0.30%

The python code used for the graph and calculations is shown below.

x = np.arange(100)

n = 100
p = 0.3
mean, var, skew, kurt = binom.stats(n, p, moments='mvsk')
print("Mean : ", mean)
print("Standard deviation :", var)

plt.xlabel('$r$')
plt.xlabel('$r$')
plt.ylabel('$B(n,p)$')
plt.title('binomial distribution n={}, p={}'.format(n,p))
plt.grid(True)

y = binom.pmf(x,n,p)
plt.scatter(x,y)
# sns.plot(x=x, y=y)
# sns.scatterplot(data=tips, x='total_bill', y='tip')

plt.show()

Mean : 30.0
Standard deviation : 21.0


## 1-2. Poisson Distribution

### Meaning of Poisson distribution

The Poisson distribution is a distribution that follows the number of random events that occur $\mu$ times per unit period. The Poisson distribution has only one parameter, this $\mu$. The formula is

$$P\left(r|\mu\right) = \frac{\mu^r}{r!}e^{-\mu}$$.

This is a good example. The following are the results of calculations for each of the cases $r=0,1,2,3,4$ for $\mu = 0.6$, following the instructions in this book.

.
.234.
$r$01234
Probability54.88%32.92%9.88%1.98%0.30%

The python code used for the graph and calculations is shown below.

from scipy.stats import poisson

x = np.arange(10)

mu = 0.6
mean, var, skew, kurt = poisson.stats(mu, moments='mvsk')
print("Mean : ", mean)
print("Standard deviation :", var)

y = poisson.pmf(x,mu)

plt.xlabel('$r$')
plt.ylabel('$P(r|\mu)$')
plt.title('Poisson distribution mu=%.1f' % (mu))
plt.grid(True)

plt.plot(x,y)

plt.show()

Mean : 0.6
Standard deviation : 0.6


## 1-3. Negative Binomial Distribution

In this chapter, the first important conclusion is written.

The purchasing behavior of individual consumers is Poisson distributed, but when we look at consumers as a whole, we see a "negative binomial distribution.


There is no description of why the distribution is negative binomial when looking at the whole consumer, and the discussion proceeds assuming a negative binomial distribution. However, as I mentioned in the previous chapter, at the bottom of p. 254 of the summary of “Poisson distribution” and “negative binomial distribution” in 1-4.

• (A) Poisson distribution at the individual level
• (ii) The long-run mean $\mu$ is gamma-distributed when viewed as a whole consumer.

• Remember that when these two assumptions hold, the actual purchase probability for a given period of time is negatively binomially distributed for the consumer as a whole.

In other words, the actual purchase probability for the entire consumer population is negative binomial. In other words, the negative binomial distribution when viewed across consumers is only the result of (a) and (i).

As a result, the probability that a certain category or a certain brand is chosen by the entire consumer is

$$P\left(r \right) = \frac{\left(1 + \frac{M}{K}\right)^{-K}\cdot \Gamma\left(K + r \right)}{\Gamma\left(r + 1 \right)}\cdot \Gamma\left(K \right) \cdot \left(\frac{M}{M+K} \right)^r \cdots \left(1 \right)$$

which can be calculated as Then, it is proved that the negative binomial distribution leads to $\left(1 \right)$ by assuming the gamma distribution as “the distribution where success calls for success”, but I think we can understand this later. Again, the important thing is that the

Assuming Poisson and Gamma distributions leads to a negative binomial distribution.


The key point is that the assumption of Poisson and Gamma distributions leads to a negative binomial distribution.

Again, the important thing to remember is that assuming a Poisson distribution and a gamma distribution leads to a negative binomial distribution, which we will prove in 1.6.

### Checking the behavior with applications

To check the behavior of the negative binomial distribution, you can use the following application.

Check

## 1-4. Summary of Poisson and Binomial Distributions

In 1.4, the subject is summarized as “Summary of Poisson and Binomial Distributions”, and the important points are, again, as follows.

• The mechanism is the same whether a consumer chooses a certain category or a certain brand. In other words, the problem of which category a consumer chooses and the problem of which brand a consumer chooses can be solved using the same probability distribution.
• The distribution of individual consumer purchases is “Poisson distributed.
• As a result of the above two points, the distribution of the number of purchases of all consumers in a certain period of time follows a “negative binomial distribution.

The causal relationship between cause and effect is different in the textbook. In the textbook, it is written that the gamma distribution is derived from the result of the Poisson distribution and the negative binomial distribution, but in the lower part of the same page, it is written that the negative binomial distribution is derived from the Poisson distribution and the gamma distribution, so I will take the position of that understanding here.

### Notation of gamma function

In general, the mathematical expression for the gamma distribution is given by using the parameters $\alpha, \beta$, which determine the shape

$$f\left(x|\alpha, \beta \right) =\frac{\beta^{\alpha}x^{\alpha - 1}e^{-\beta x}}{\Gamma\left(\alpha \right)}\cdot\cdot\cdot\left(1\right)$$

This is expressed as Also, as $\displaystyle \beta =\frac{1}{\theta}$

$$f\left(x|\alpha, \theta \right) =\frac{x^{\alpha - 1}e^{-frac{x}{\theta}}}{\Gamma\left(\alpha \right)}\theta^{\alpha} \cdot \cdot \cdot \left(2\right)$$

These two formulas are also used in wikipedia. Here, the mean and standard deviation of the probability distribution in (1) and (2) are as follows