Price optimization: maximizing revenue/profit

Problem statement

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. Two determinants/indicators of business revenue are product prices and quantity sold. At higher price revenue is expected to be higher, if quantity sold is constant. However we know from our everyday experience that price and quantity are inversely related – as the price of something goes up, people have less tendency to buy it.

The opposite is also true, that is, as price goes down, sales go up (that’s why we big “sale” events in shopping malls round the year). But that doesn’t mean that the revenue will always go up.

So the big question is: if higher price means sales down and at lower price revenue goes down then where is the sweet spot, the right price, that maximizes revenue ?

So ?

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 for 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 that information to find at what price the profit is maximized.

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

# View 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