Skip to main content

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.

freeridebanner

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()

equilibrium.svg

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

freeride-0.1.1.tar.gz (42.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

freeride-0.1.1-py3-none-any.whl (51.2 kB view details)

Uploaded Python 3

File details

Details for the file freeride-0.1.1.tar.gz.

File metadata

  • Download URL: freeride-0.1.1.tar.gz
  • Upload date:
  • Size: 42.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for freeride-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b9c3b8dbf50e3a2a292e9c19adaa760d23f7711185922e1bd90f52245f11d9d8
MD5 bbb3e3c3efe8bcedcf9d1bb140d6be6d
BLAKE2b-256 843e15448a367c33a23db8a90fef3d4d580a6175931665721620c0e82bfbed42

See more details on using hashes here.

File details

Details for the file freeride-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: freeride-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 51.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.22

File hashes

Hashes for freeride-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9fcee52ea90537e7d1c0401bd9fb90cc8f9b5adf0c5a3433caaf578d3d113e0e
MD5 aa746bb0105be1225d635236dfa7594a
BLAKE2b-256 0fb0a6535081f0ea0412742c3f8f8b65839bd48680fc639ee2fad5d2b5e70135

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page