pyMicroeconomics is a Python package designed for symbolic analysis and visualization of market equilibrium conditions. This package allows you to define various supply and demand curves, calculate market equilibrium points, and visualize these using interactive plots. It integrates several powerful libraries, such as Sympy and Matplotlib, making it a versatile tool for microeconomic analysis.
- Define different types of supply and demand curves (linear, power, exponential, quadratic).
- Calculate key market metrics, including equilibrium price and quantity.
- Compute consumer surplus, producer surplus, and total surplus.
- Visualize market equilibrium interactively with ipywidgets and Matplotlib.
To get started with pyMicroeconomics, follow these steps:
- Python 3.8 or later
- Jupyter Notebook or JupyterLab for interactive usage
To install pyMicroeconomics, use pip:
pip install pyMicroeconomics
This package is intended to be used interactively within Jupyter Notebooks to visualize economic concepts dynamically.
You can also use the provided Dockerfile and devcontainer.json to set up a complete development environment. This is especially useful if you use Visual Studio Code or GitHub Codespaces. To start developing with pyMicroeconomics, clone the repository and spin up a Docker container:
git clone https://github.com/joshhilton/pyMicroeconomics.git
cd pyMicroeconomics
docker build -t pymicroeconomics .
docker run -it -v $(pwd):/app pymicroeconomics
Below is a simple example of finding the market equilibrium using linear supply and demand curves:
import pyMicroeconomics as pm
# Define demand and supply curves
demand = pm.linear_demand()
supply = pm.linear_supply()
# Calculate equilibrium
equilibrium = pm.market_equilibrium(demand, supply)
# Display equilibrium details
pm.display_equilibrium(equilibrium)
pm.plot_equilibrium(equilibrium)
This visualization allows users to adjust the parameters interactively and observe changes in real-time.
The complete documentation for pyMicroeconomics, including detailed guides, examples, and the API reference, is available here.
If you need specific help on running tests or contributing, check out the Developer Guide and Testing Guide in the docs/
directory.
We welcome contributions to the project! Please follow these steps to get involved:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/AmazingFeature
). - Commit your changes (
git commit -m 'Add some AmazingFeature'
). - Push to the branch (
git push origin feature/AmazingFeature
). - Open a Pull Request.
Please refer to the CONTRIBUTING.md document for more detailed guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built using SymPy, Matplotlib, and ipywidgets.
If you have any questions or need further help, please feel free to open an issue on GitHub.