Table of Contents
Introduction
What Is a Price-Relative Index?
Understanding the Simple Average Method
Real-World Scenario: Monitoring Global Coffee Price Volatility
Step-by-Step Calculation
Complete Implementation with Test Cases
Best Practices and Pitfalls to Avoid
Conclusion
Introduction
In today’s volatile global markets, businesses need fast, reliable ways to track price changes across multiple goods. One of the oldest yet most effective tools is the Price-Relative Index, and its simplest form—the Simple Average of Price Relatives—offers clarity without complexity.
This article walks you through the concept, shows you how to compute it in clean Python code, and applies it to a timely real-world challenge: tracking how global coffee prices shift across major exporting countries. Whether you're in supply chain, finance, or data analytics, this technique is a must-have in your toolkit.
What Is a Price-Relative Index?
A price relative compares the price of a single item in the current period to its price in a base period:
![qa]()
The Simple Average of Price Relatives takes the arithmetic mean of all individual price relatives in a basket, giving equal importance to each item.
Understanding the Simple Average Method
Unlike weighted indices (which consider economic importance), this method treats all items equally. It’s ideal when:
Formula:
![c]()
Where n is the number of items.
Real-World Scenario: Monitoring Global Coffee Price Volatility
You work for a specialty coffee importer sourcing beans from Brazil, Colombia, Vietnam, Ethiopia, and Honduras. Each month, you receive local farmgate prices (in USD per pound). Your CEO asks: “On average, how much more expensive is coffee this month compared to January?”
Since each origin is equally important to your blend, you use the Simple Average of Price Relatives—no weighting needed, just pure price movement insight.
Step-by-Step Calculation
For each country, compute: (current_price / base_price) * 100
Sum all price relatives
Divide by the number of countries
Interpret: >100 = overall price increase
Complete Implementation with Test Cases
from typing import List
import unittest
def simple_average_price_relative_index(base_prices: List[float], current_prices: List[float]) -> float:
"""
Calculate the Simple Average of Price-Relative Index.
Args:
base_prices: Prices in base period (e.g., January)
current_prices: Prices in current period (e.g., June)
Returns:
Index number (e.g., 108.5 means 8.5% average price increase)
Raises:
ValueError: If inputs are invalid (empty, unequal length, or zero base prices)
"""
if not base_prices or not current_prices:
raise ValueError("Price lists cannot be empty")
if len(base_prices) != len(current_prices):
raise ValueError("Base and current price lists must have the same length")
if any(p == 0 for p in base_prices):
raise ValueError("Base prices cannot be zero")
relatives = [(curr / base) * 100 for base, curr in zip(base_prices, current_prices)]
index = sum(relatives) / len(relatives)
return round(index, 2)
class TestPriceRelativeIndex(unittest.TestCase):
def test_basic_increase(self):
base = [2.0, 2.2, 1.8, 2.5, 2.1] # Jan prices (USD/lb)
current = [2.2, 2.4, 2.0, 2.6, 2.3] # Jun prices
index = simple_average_price_relative_index(base, current)
# Corrected Expected: (110.0 + 109.0909.. + 111.1111.. + 104.0 + 109.5238..) / 5 ≈ 108.75
self.assertAlmostEqual(index, 108.75, places=2)
def test_no_change(self):
prices = [1.5, 2.0, 3.0]
index = simple_average_price_relative_index(prices, prices)
self.assertEqual(index, 100.0)
def test_mixed_changes(self):
base = [10, 20]
current = [12, 18] # Relatives: 120.0, 90.0. Average: (120+90)/2 = 105.0
index = simple_average_price_relative_index(base, current)
self.assertEqual(index, 105.0)
def test_error_cases(self):
with self.assertRaises(ValueError):
simple_average_price_relative_index([], [1])
with self.assertRaises(ValueError):
simple_average_price_relative_index([1, 2], [3])
with self.assertRaises(ValueError):
simple_average_price_relative_index([0, 1], [2, 3])
if __name__ == "__main__":
# Coffee price data (USD per pound)
jan_prices = [2.10, 2.30, 1.90, 2.40, 2.00] # Brazil, Colombia, Vietnam, Ethiopia, Honduras
jun_prices = [2.25, 2.50, 2.10, 2.35, 2.15]
index = simple_average_price_relative_index(jan_prices, jun_prices)
print("=== Global Coffee Price-Relative Index ===")
print(f"Base Period: January")
print(f"Current Period: June")
print(f"Simple Average Price-Relative Index: {index}")
if index > 100:
print(f"→ Average coffee prices increased by {index - 100:.2f}%")
elif index < 100:
print(f"→ Average coffee prices decreased by {100 - index:.2f}%")
else:
print("→ No average price change")
# Run tests
unittest.main(argv=[''], exit=False, verbosity=2)
![qw]()
Best Practices and Pitfalls to Avoid
Ensure base prices are non-zero—division by zero breaks the calculation.
Match items precisely—don’t swap Brazil’s January price with Colombia’s.
Don’t use for policy decisions without weighting—a 50% spike in a minor origin gets same weight as a major one.
Combine with raw data—show both the index and individual price relatives for full context.
Use consistent currency and units—convert all prices to USD/lb before computing.
Conclusion
The Simple Average of Price-Relative Index is a transparent, easy-to-explain metric perfect for monitoring multi-item price trends—especially in global commodity markets like coffee, grains, or energy. By implementing it correctly, you turn scattered price data into a single, actionable insight. In a world of algorithmic complexity, sometimes the simplest index speaks the loudest truth.