4

 import numpy as np

import matplotlib.pyplot as plt

import seaborn as sns


# Simulate a skewed salary distribution (e.g., exponential distribution)

np.random.seed(42)

population = np.random.exponential(scale=70000, size=10000) # Skewed salaries


# Take 10 random samples, each with 50 salaries, and compute their means

sample_means = []

for _ in range(10):

sample = np.random.choice(population, size=50, replace=True)

sample_means.append(np.mean(sample))


# Plotting the sample means distribution

plt.figure(figsize=(8, 5))

sns.histplot(sample_means, bins=10, kde=True, color='skyblue', edgecolor='black')

plt.title("Sampling Distribution of Mean Salaries (10 samples of size 50)")

plt.xlabel("Sample Mean Salary")

plt.ylabel("Frequency")

plt.grid(True)

plt.tight_layout()

plt.show()

Comments

Popular posts from this blog

2

5

1