411 REFERENCE · Wikibooks
Scientific Calculations with Julia/Supply and Demand
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Scientific Calculations with Julia Supply and Demand Basic Model of Sports Betting Game Theory
The supply curve is a graphical representation of the different quantities of a good or service that producers are willing to supply at different prices.
Notice that this curve rises as the price increases.
Suppose we have a market for chocolate bars and want to construct the supply curve for them. We must first collect data on the quantities of bars that producers are willing to supply at different prices. Here is a hypothetical table of data:
| Price (€ per bar) | Quantity Supplied (bars) |
|-------------------------|----------------------------|
| 2 | 100 |
| 3 | 150 |
| 4 | 250 |
| 5 | 300 |
| 6 | 400 |
| 7 | 450 |
The demand curve represents the relationship between the price of a good or service and the quantity of that good or service that consumers are willing to purchase at different price levels.
Note that this curve decreases as the price increases.
By collecting data on the quantities of chocolate bars that consumers are willing to purchase at different prices, we can construct the following hypothetical data table:
| Price (€ per bar) | Quantity Demanded (bars) |
|-------------------------|------------------------------|
| 2 | 500 |
| 3 | 450 |
| 4 | 300 |
| 5 | 200 |
| 6 | 150 |
| 7 | 100 |
Using Julia's Interpolations and Plots libraries, you can plot the two curves and see where they intersect:
using Interpolations, Plots
#Supply Curve
y=[100,150,250,300,400,450]
x= 2:7
itp =interpolate((x,),y, Gridded(Linear()))
plot(2:0.01:7, [itp(i) for i in 2:0.01:7],
label="Supply Interp.", title="Supply and Demand Curves", linewidth=2)
scatter!(x,y, label="Supply Data", legend=:right)
#Demand Curve
y1=[500,450,300,200,150,100]
itp =interpolate((x,),y1, Gridded(Linear()))
plot!(2:0.01:7, [itp(i) for i in 2:0.01:7], label="Interpolated demand", linewidth=2)
scatter!(x,y1, label="Demand data", legend=:right)
thumb|center|500px
At a price of approximately €4.30, the two curves intersect with a quantity of approximately 250 bars.
The equilibrium price, obtained from the intersection of the supply and demand curves, is a fundamental condition in the market economy and has several important characteristics:
. Quantity traded: The equilibrium price determines the quantity of a good or service that will actually be traded on the market. This quantity is given by the ordinate (the value on the x-axis) of the intersection between the demand and supply curves.
. Stability: The equilibrium price is stable in the sense that, unless market conditions change, producers and consumers tend to be satisfied at this price. There is no immediate pressure to increase or decrease the quantities supplied or demanded.
. Allocative efficiency: The equilibrium price reflects the optimal allocation of resources in a competitive market economy. In other words, resources are allocated in such a way as to maximize the overall well-being of society. This is often referred to as the Pareto optimum.
. No surplus: At the equilibrium price, there is no excess in either demand or supply. This means that the quantity supplied equals the quantity demanded. There are no accumulated inventories (excess supply) nor consumers who want to buy more than is available (excess demand).
. Price and quantity fixed: Unless market conditions change, the equilibrium price and quantity traded remain stable over time. This provides an important reference point for producers' production decisions and consumers' purchasing decisions.
. Competition: The equilibrium price typically occurs in competitive markets where numerous producers and consumers act independently. Competition is often a key factor in achieving equilibrium.
. Automatic adjustment: In response to any change in market conditions, the equilibrium price tends to adjust automatically. For example, if demand increases, the price tends to rise to reflect the increased quantity demanded. If supply increases, the priceIt tends to decrease to reflect increased availability.