This project explores the Central Limit Theorem by simulating daily LinkedIn usage times and analyzing the distribution of average daily time spent across multiple simulations.
The script simulates daily time spent on LinkedIn using a normal distribution with a specified mean and standard deviation. We then run multiple simulations, calculating the average daily time spent for each simulated sample. Finally, we analyze the distribution of these average times, demonstrating the Central Limit Theorem, which states that the sampling distribution of the means approaches a normal distribution regardless of the underlying population distribution (as long as the sample size is sufficiently large).
new_mean_daily_time: This variable stores the assumed average daily time spent on LinkedIn (in minutes). You can replace this value with your own estimate.daily_linkedin_timefunction: This function simulates a single day's LinkedIn usage time using a normal distribution with the defined mean and a standard deviation of 10 minutes (adjustable).sample_sizeandnum_simulations: These variables define the number of users simulated per sample and the total number of simulations run, respectively. You can adjust these values based on your needs.- Simulation Loop: The code iterates
num_simulationstimes. In each iteration:- A sample of
sample_sizedaily usage times is generated usingdaily_linkedin_time. - The average daily time spent for that sample is calculated and appended to the
sample_meanslist.
- A sample of
- Visualization: The script uses Matplotlib (assumed) to create a histogram visualizing the distribution of the average daily time spent values across all simulations.
- Summary Statistics: The code calculates and prints the overall average daily time spent and the standard deviation of the average daily time spent across all simulations.
By running multiple simulations and observing the distribution of average daily time spent in the sample_means list, we expect to see a normal distribution emerge even though the underlying daily usage times follow a normal distribution. This reinforces the Central Limit Theorem principle.
- Ensure you have Python 3 and the required libraries installed (
random,numpy, andmatplotlib). - Modify
new_mean_daily_timeif you want a different average daily time. - Adjust
sample_sizeandnum_simulationsfor your desired sample and simulation count. - Run the script using
python your_script_name.py.
The script will generate a visualization and print summary statistics about the average daily time spent across simulations.