Engineering Probability and Statistics – University of Tehran – Department of Electrical & Computer Engineering
This repository contains Bayesian Estimation, Joint Distributions, and Correlation Analysis, a probability and statistics analysis project implemented in Python and Jupyter Notebook. This project was developed as the Second Computer Assignment for the Engineering Probability and Statistics course at the University of Tehran.
The project follows a complete computational statistics pipeline, including queue-system simulation, empirical distribution visualization, Bayesian posterior updating with Beta-Bernoulli conjugacy, manual Pearson correlation estimation, conditional-distribution analysis, and final discussion of correlation versus causality.
The implementation is organized into three standardized notebooks, each corresponding to one major assignment section: queue-system joint distributions, Bayesian coin-flip estimation, and energy/correlation analysis.
- ✅ Simulate a single-server queue and analyze
arrival_times,wait_times,service_times, andtotal_times. - ✅ Visualize marginal and joint distributions using histograms, KDE curves, scatter plots, and joint plots.
- ✅ Estimate the probability of heads in coin-flip data using Beta-Bernoulli Bayesian updating.
- ✅ Convert time-series energy data to datetime features and inspect yearly, hourly, and monthly consumption patterns.
- ✅ Implement Pearson correlation manually without relying on
pandas.DataFrame.corr(). - ✅ Compare correlation results and explain why correlation alone does not establish causality.
The first notebook simulates an M/M/1-style queue with one service counter. It records aligned customer-level arrays for arrival time, waiting time, service time, and total time in the system. The notebook then visualizes the requested marginal and joint distributions and computes the Pearson correlation coefficient between arrival time and waiting time.
The second notebook applies the Beta-Bernoulli conjugate model to coin_flips.txt. Posterior distributions are updated after every 50 flips under two priors: Beta(1, 1) and Beta(4, 10). Final posterior means and variances are reported and compared with the empirical head frequency.
The third notebook loads energy.csv, converts Datetime values to pandas datetime objects, extracts year/month/day/hour features, and uses boxplots to inspect consumption patterns. It then computes selected correlations manually for hour-energy and month-energy windows.
The final analysis uses TV_LE_Physician.csv to compare life expectancy, physicians per 1,000 people, and televisions per 1,000 people. The notebook distinguishes descriptive correlation from causal interpretation and notes that confounding variables must be considered before making causal claims.
The project is organized as follows:
Bayesian-Estimation-Joint-Distribution-Correlation/
├── data/ # Assignment datasets and input files
├── description/ # Original assignment specification
├── notebooks/ # Standardized Jupyter notebooks
├── .gitignore # Git exclusion rules for Python and Jupyter work
├── requirements.txt # Python dependencies
└── README.md # Project documentation
Create a virtual environment and install the required packages:
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txtLaunch Jupyter Notebook from the repository root:
jupyter notebook notebooksTo execute the notebooks from the command line, run:
jupyter nbconvert --to notebook --execute notebooks/01_queue_joint_distribution.ipynb --inplace --ExecutePreprocessor.timeout=180
jupyter nbconvert --to notebook --execute notebooks/02_bayesian_coin_estimation.ipynb --inplace --ExecutePreprocessor.timeout=180
jupyter nbconvert --to notebook --execute notebooks/03_energy_correlation_analysis.ipynb --inplace --ExecutePreprocessor.timeout=240The queue simulation generated 49,940 customers with the fixed assignment seed. The manual Pearson correlation between arrival_times and wait_times was approximately 0.082207, indicating weak linear association under the selected simulation parameters.
The coin-flip dataset contains 1,000 observations with 365 heads and 635 tails. The final posterior mean for the probability of heads is approximately 0.365269 under the uniform prior and 0.363905 under the Beta(4, 10) prior.
For the energy dataset, the sample variance of AEP_MW is higher in 2005 than in 2004. The selected correlation windows show a positive hour-energy correlation from 04:00 to 13:00, a negative month-energy correlation from months 2 to 4, and a positive month-energy correlation from months 10 to 12.
In the life-expectancy dataset, physicians per 1,000 people have a moderate positive correlation with life expectancy, while televisions per 1,000 people have almost no linear correlation with life expectancy. The notebook treats these as associations, not causal proof.
The original Persian assignment statement is retained in description/EPS_CA2.pdf. All notebooks use relative paths through the repository-level data/ directory and can be executed from the repository root.