A package for undergraduate microeconomics.
Project description
FreeRide
This is a package for introductory microeconomics topics. Find additional code, albeit unpackaged, in the loose-code branch.
Example Usage
Demand and Supply objects can be created in several ways, but most naturally with the from_formula class method. The method requires an explicit slope, so "P=12-1*Q" or "P=12-1Q" must be used instead of "P=12-Q".
from freeride.curves import Demand, Supply
d1 = Demand.from_formula("Q = 10 - 1*P")
d2 = Demand.from_formula("P = 15 - 2*Q")
s1 = Supply.from_formula('Q = 2*P')
s2 = Supply.from_formula('Q = 2*P - 1')
Formula strings that don't match the expected patterns raise
FormulaParseError for quick troubleshooting.
The addition operator performs horizontal summation, allowing aggregation.
d = d1 + d2
s = s1 + s2
Then you can solve for and plot an equilibrium.
from freeride.equilibrium import Equilibrium
e = Equilibrium(d, s)
print(e.p, e.q)
e.plot()
Use matplotlib to customize plots further.
import matplotlib.pyplot as plt
ax = e.plot()
ax.set_ylim(0, 16)
# Label curves
ax.text(2, d(2) + 0.05,
s='D',
fontsize=16,
horizontalalignment='left',
verticalalignment='bottom')
ax.text(16, s(16) + 0.05,
s='S',
fontsize=16,
horizontalalignment='right',
verticalalignment='bottom')
# Label equilibrium
ax.text(e.q, e.p + 2,
s=f'Q={e.q:.2f}, P={e.p:.2f}',
horizontalalignment='center',
verticalalignment='bottom')
plt.savefig("equilibrium.svg", transparent=True)
plt.show()
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file freeride-0.1.0.tar.gz.
File metadata
- Download URL: freeride-0.1.0.tar.gz
- Upload date:
- Size: 42.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f32ec567f50845de5a8824ea071a2ff13423f2c2b11d918db474a7d7f108e50
|
|
| MD5 |
455628465724d67c9cca17ee1ec3ee2f
|
|
| BLAKE2b-256 |
83e3e35249b4bd8cfa8b57b638a6a94b9b36b34fdab13338dd3b35494beb8ad7
|
File details
Details for the file freeride-0.1.0-py3-none-any.whl.
File metadata
- Download URL: freeride-0.1.0-py3-none-any.whl
- Upload date:
- Size: 50.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.22
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07ea31dc15e164936bb38c2ec5f32bcc0ded29e626dccdbd9d93deb6024d6dc9
|
|
| MD5 |
0522417493cc4abfaef44af37b31a485
|
|
| BLAKE2b-256 |
f35407186062d1ca83188caedb80add006eb0fb37a3a12947e00f5da80d10b4d
|