diff --git a/myplot.png b/myplot.png new file mode 100644 index 0000000..3375eb1 Binary files /dev/null and b/myplot.png differ diff --git a/plot.py b/plot.py new file mode 100644 index 0000000..3ccf8b1 --- /dev/null +++ b/plot.py @@ -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) + + diff --git a/solution_.md b/solution_.md new file mode 100644 index 0000000..b9fd8ff --- /dev/null +++ b/solution_.md @@ -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.