Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added myplot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions plot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

df = pd.read_csv("istherecorrelation.csv", sep=";")
df["WO [x1000]"] = df["WO [x1000]"].str.replace(",", ".").astype(float)

x = df["WO [x1000]"]
y = df["NL Beer consumption [x1000 hectoliter]"]

plt.figure(dpi=300)
plt.scatter(x, y, color="blue", label="Data points")
coeffs = np.polyfit(x, y, 1)
poly_eq = np.poly1d(coeffs)
plt.plot(x, poly_eq(x), color="red", label=f"Fit line: y={coeffs[0]:.2f}x+{coeffs[1]:.2f}")
plt.xlabel("WO (x1000 students)")
plt.ylabel("Beer consumption (x1000 hectoliter)")
plt.title("Relationship between WO and Beer consumption in NL")
plt.legend()
plt.savefig("myplot.png")
plt.show()


r = df["WO [x1000]"].corr(df["NL Beer consumption [x1000 hectoliter]"])
print("Correlation coefficient r =", r)


25 changes: 25 additions & 0 deletions solution_.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Solution

**StudentID:** 16092228

## Papers
- MCC Van Dyke et al., 2019
- JT Harvey, Applied Ergonomics, 2002
- DW Ziegler et al., 2005

## Plot and Correlation Analysis

![My Plot](myplot.png)

To examine the relationship between the number of university students (WO) and beer consumption in the Netherlands,
we created a scatter plot and calculated the **Pearson correlation coefficient (r)**.

The computed value is:

**r = 0.818**

Since |r| > 0.8, this indicates a **strong positive correlation** between WO and beer consumption.
In other words, as the number of university students increases, the data also shows an increase in beer consumption.

However, this relationship may be just coincidental.
The observed correlation might be influenced by other factors or simply reflect parallel trends in the data.