The following is a cheesy blogpost using Jupyter Notebook.

In [2]:
# Cheese and Happiness: A Cheesy Analysis 🧀😄

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy.stats import pearsonr

# Generating some fictional data
np.random.seed(42)
population_size = 100

# Amount of cheese consumed per year (in kg)
cheese_consumption = np.random.normal(loc=10, scale=3, size=population_size)
cheese_consumption = np.clip(cheese_consumption, 0, None)  # No negative cheese consumption

# Happiness score on a scale from 1 to 10
# We make it up that more cheese -> more happiness with some random noise
happiness = 5 + 0.5 * cheese_consumption + np.random.normal(loc=0, scale=2, size=population_size)
happiness = np.clip(happiness, 1, 10)  # Happiness scores should be between 1 and 10

# Creating a DataFrame
data = pd.DataFrame({
    'Cheese Consumption (kg/year)': cheese_consumption,
    'Happiness Score': happiness
})

# Display the first few rows of the data
print("Let's take a look at our cheesy data:")
display(data.head())

# Plotting the data
plt.figure(figsize=(10, 6))
plt.scatter(data['Cheese Consumption (kg/year)'], data['Happiness Score'], color='orange')
plt.title('Happiness vs. Cheese Consumption')
plt.xlabel('Cheese Consumption (kg/year)')
plt.ylabel('Happiness Score')
plt.grid(True)
plt.show()

# Calculating the correlation
correlation, _ = pearsonr(data['Cheese Consumption (kg/year)'], data['Happiness Score'])

print(f"\nThe correlation between cheese consumption and happiness is a delicious {correlation:.2f}.")

# Conclusion with a humorous twist
if correlation > 0.5:
    conclusion = "It seems like the more cheese you eat, the happier you get! So, don't feel guilty about that extra slice of cheddar."
elif correlation > 0:
    conclusion = "There's a slight cheesy effect on happiness. Maybe it's time to experiment with some Gouda?"
else:
    conclusion = "The data doesn't lie. Maybe it's time to explore other sources of happiness. Have you tried chocolate?"

print(f"\nConclusion: {conclusion}")
Let's take a look at our cheesy data:
Cheese Consumption (kg/year) Happiness Score
0 11.490142 7.914330
1 9.585207 8.951313
2 11.943066 10.000000
3 14.569090 10.000000
4 9.297540 9.326199
No description has been provided for this image
The correlation between cheese consumption and happiness is a delicious 0.43.

Conclusion: There's a slight cheesy effect on happiness. Maybe it's time to experiment with some Gouda?