Price optimization: maximizing revenue/profit

Problem statement

Two determinants of business revenue/profit are the price of the products and how many of them are sold. At higher price the revenue is expected to be high. But this is not the case all the time. We know from our everyday experience, as the price of something goes up, people have less tendency to buy it.

The reverse is also true, that is, as price goes down, sales goes up (think what happens in a block buster sales event in a nearby shopping mall). But that doesn’t mean that the revenue will always go up too.

Setting a right price of products/services is one of the most important decisions a business can make. Under-pricing and over-pricing both can hurt a company’s bottom line. So where is the sweet spot, the right price, that maximizes revenue?

With a simple example let’s examine how to optimization price to maximize revenue/profit.

Import libraries

from __future__ import print_function
import numpy as np
import pandas as pd
from pandas import DataFrame
import matplotlib.pyplot as plt
import seaborn as sns
import statsmodels.api as sm
from statsmodels.compat import lzip
from statsmodels.formula.api import ols
%matplotlib inline


Data in this analysis came from here [Susan Li has a nice blog post about price elasticity of demand (i.e. sensitivity of demand to change in price) explained using the same dataset]. This is a time series, quarterly data of beef sales (quantity) and its corresponding price.

This data will be used first to find price elasticity of demand and then to use this information to find at what price the profit is maximized.

# Load data
data_source =
beef = pd.read_csv('data_source')

# View first few rows
# demand curve estimation
sns.lmplot( x="Price", y="Quantity", data=beef, fit_reg=True, size=4)
# fit OLS model
model = ols("Quantity ~ Price", data=beef).fit()
# print model summary 
Price = [320, 330,340,350, 360, 370, 380, 390] # a range of diffferent prices to find the optimum one
Cost = 80 # a fixed cost in this case
Revenue = []
for i in Price:
    Revenue.append((i-cost)*quantity_demanded) # profit function

# create data frame of price and revenue 
profit=pd.DataFrame({"Price": Price, "Revenue": Revenue})
#plot revenue against price
plt.plot(profit["Price"], profit["Revenue"])
# price at which the revenue is maximum
profit[profit['Revenue'] == profit['Revenue'].max()]

One thought on “Price optimization: maximizing revenue/profit

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s