Skip to content

Instantly share code, notes, and snippets.

@bondarewicz
Last active August 29, 2015 14:18
Show Gist options
  • Save bondarewicz/fd6864c18397874aa219 to your computer and use it in GitHub Desktop.
Save bondarewicz/fd6864c18397874aa219 to your computer and use it in GitHub Desktop.
price elasticity of demand
//http://en.wikipedia.org/wiki/Price_elasticity_of_demand
//In general, the demand for a good is said to be inelastic (or relatively inelastic) when the PED is less than one (in absolute value):
//that is, changes in price have a relatively small effect on the quantity of the good demanded.
//The demand for a good is said to be elastic (or relatively elastic) when its PED is greater than one (in absolute value):
//that is, changes in price have a relatively large effect on the quantity of a good demanded.
//Revenue is maximized when price is set so that the PED is exactly one.
<?php
//original_quantity
$oq = 50;
//new quantity
$nq = 30;
//original price
$op = 20;
//new price
$np = 25;
//Change in Quantity = ((New Quantity - Original Quantity) / Original Quantity)
$chiq = ($nq - $oq) / $oq;
//Change in Price = ((New Price - Original Price) / Original Price)
$chip = ($np - $op) / $op;
//Price Elasticity (PED or Ed) = Change in Quantity / Change in Price Where,
$ped = $chiq / $chip;
print abs($ped); // 1.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment